/*
  Partial solution to problem on livearchive 
http://livearchive.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=532&page=show_problem&problem=3794

  Judged correct.

  To compile, run:
  g++ 5783.cpp
  ./a.out < testFile.txt

  For testFile.txt, copy/paste the test input from the online judge website.
 */

#include <stdio.h>
#include <math.h>

#include <iostream>
#include <cmath>

using namespace std;

int main() {
  int a, b;
  int caseNum = 0;

  while (1) { 
    caseNum++;

    cin >> a >> b;

    if (a == 0 and b == 0)
      break;

    int x = 0;
    int count = 0;
    int sq = 1, sqN=1;
    for(int i=0; x+1 < b; i++) {
      x += i; // x is a triangle number

      while (sq < x+1) { // sq is a square that is >= x+1.
	sqN++; sq = sqN * sqN; 
      }

      if (x+1 > a && x+1 < b && x+1 == sq) 
	count++;
    }

    printf("Case %d: %d\n", caseNum, count);
  }

  return 0;
}
