#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
/* Ham tinh phu cho ban nao can ^^.
int ktcp (long long u)
{
long long tmp =sqrt (u);
if (tmp*tmp==u) return 1;
else return 0;
}
int ktXepTG (long long x)
{
long long denta = 1+8*x;
long long tmp=sqrt (denta);
if ((tmp*tmp)==denta && (-1+tmp)%2==0) return 1;
return 0;
}
*/
int main ()
{
/* Tinh truoc 10^9 so:
vector <long long> v;
for (long long u=2; u<=1000000000-1; u++)
{
if (ktcp (u)==1 && ktXepTG (u-1)==1) v.push_back (u);
}
*/
//Se co cac so t/m la:
long long v[] = {4, 16, 121, 529, 4096, 17956, 139129, 609961, 4726276, 20720704, 160554241, 703893961}; //|| ^^ ||
long long a, b;
int t=0;
while (1)
{
cin>>a>>b;
if (a==0 && b==0) break;
t++;
long long k=0;
for (int i=0; i<12; i++)
{
if (v[i]>a && v[i]<b) k++;
}
cout<<"Case "<<t<<": "<<k<<endl;
}
return 0;
}