package fixjava;

public class StringUtils {

	/** Repeat the given string the requested number of times. */
	public static String repeat(String str, int numTimes) {
		StringBuilder buf = new StringBuilder(Math.max(0, str.length() * numTimes));
		for (int i = 0; i < numTimes; i++)
			buf.append(str);
		return buf.toString();
	}

	/**
	 * Pad the left hand side of a field with the given character. Always adds at least one pad character. If the length of str is
	 * greater than numPlaces-1, then the output string will be longer than numPlaces.
	 */
	public static String padLeft(String str, char padChar, int numPlaces) {
		int bufSize = Math.max(numPlaces, str.length() + 1);
		StringBuilder buf = new StringBuilder(Math.max(numPlaces, str.length() + 1));
		buf.append(padChar);
		for (int i = 1, mi = bufSize - str.length(); i < mi; i++)
			buf.append(padChar);
		buf.append(str);
		return buf.toString();
	}

	/**
	 * Pad the right hand side of a field with the given character. Always adds at least one pad character. If the length of str is
	 * greater than numPlaces-1, then the output string will be longer than numPlaces.
	 */
	public static String padRight(String str, char padChar, int numPlaces) {
		int bufSize = Math.max(numPlaces, str.length() + 1);
		StringBuilder buf = new StringBuilder(Math.max(numPlaces, str.length() + 1));
		buf.append(str);
		buf.append(padChar);
		while (buf.length() < bufSize)
			buf.append(padChar);
		return buf.toString();
	}

	/** Intern all strings in an array, skipping null elements. */
	public static String[] intern(String[] arr) {
		for (int i = 0; i < arr.length; i++)
			arr[i] = arr[i].intern();
		return arr;
	}

	/** Intern a string, ignoring null */
	public static String intern(String str) {
		return str == null ? null : str.intern();
	}

}

public class A {
   public static void main(String[] a) {
       //System.out.println(a(1,9));
       //System.out.println(a(10,40));
       //System.out.println(a(100,500));
       //System.out.println(a(1111,2222));

       java.io.BufferedReader reader = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
       int i=0;
       String line = null;
       try {
       while((line=reader.readLine())!=null) {
          if(i>0) {
              System.out.println("Case #"+i+": "+parseLine(line));
          }
          i++;
       
       } 
       } catch(Exception e) {}
   }

   static int parseLine(String line) {
       String p[] = line.split(" ");
       return a(Integer.valueOf(p[0]), Integer.valueOf(p[1]));
   }

   public static int a(int a, int b) {
      if(a>=b) return 0;
      if(b<10) return 0; //1 digit. return 0

      java.util.HashMap<Integer, Byte> map = new java.util.HashMap<Integer, Byte>();
      int count=0;
      for(int i=a;i<=b;i++) {
          String x = String.valueOf(i);
          map.clear();
          for(int j=1; j<x.length();j++) {
              String y1 = x.substring(j);
              String y2 = x.substring(0, j);
              if(y1.charAt(0)=='0') continue;

              String y = y1 + y2;
              int m = Integer.valueOf(y);

              //System.out.println(i+"m"+m+","+y+","+x+"j"+j);
              if(a<=m && m<=b) { 
                  //System.out.println(i+","+m);
                  if(i<m && map.get((i+","+m).hashCode())==null) {
                      //System.out.println("zx"+i+","+m);
                      map.put((i+","+m).hashCode(), (byte)0);
                      count++;
                  } /*else if(map.get((i+","+m).hashCode())!=null){
                     System.out.println(i+","+m);
                  }*/
              }
          }
      }

      return count;
   }
}
