package jp.funnything.competition.util;

import java.math.BigInteger;

/**
 * Utility for BigInteger
 */
public class BI {
    public static BigInteger ZERO = BigInteger.ZERO;
    public static BigInteger ONE = BigInteger.ONE;

    public static BigInteger add( final BigInteger x , final BigInteger y ) {
        return x.add( y );
    }

    public static BigInteger add( final BigInteger x , final long y ) {
        return add( x , v( y ) );
    }

    public static BigInteger add( final long x , final BigInteger y ) {
        return add( v( x ) , y );
    }

    public static int cmp( final BigInteger x , final BigInteger y ) {
        return x.compareTo( y );
    }

    public static int cmp( final BigInteger x , final long y ) {
        return cmp( x , v( y ) );
    }

    public static int cmp( final long x , final BigInteger y ) {
        return cmp( v( x ) , y );
    }

    public static BigInteger div( final BigInteger x , final BigInteger y ) {
        return x.divide( y );
    }

    public static BigInteger div( final BigInteger x , final long y ) {
        return div( x , v( y ) );
    }

    public static BigInteger div( final long x , final BigInteger y ) {
        return div( v( x ) , y );
    }

    public static BigInteger mod( final BigInteger x , final BigInteger y ) {
        return x.mod( y );
    }

    public static BigInteger mod( final BigInteger x , final long y ) {
        return mod( x , v( y ) );
    }

    public static BigInteger mod( final long x , final BigInteger y ) {
        return mod( v( x ) , y );
    }

    public static BigInteger mul( final BigInteger x , final BigInteger y ) {
        return x.multiply( y );
    }

    public static BigInteger mul( final BigInteger x , final long y ) {
        return mul( x , v( y ) );
    }

    public static BigInteger mul( final long x , final BigInteger y ) {
        return mul( v( x ) , y );
    }

    public static BigInteger sub( final BigInteger x , final BigInteger y ) {
        return x.subtract( y );
    }

    public static BigInteger sub( final BigInteger x , final long y ) {
        return sub( x , v( y ) );
    }

    public static BigInteger sub( final long x , final BigInteger y ) {
        return sub( v( x ) , y );
    }

    public static BigInteger v( final long value ) {
        return BigInteger.valueOf( value );
    }
}

import java.io.*;
import java.util.Scanner;
import java.util.*;

public class B {
	public static int reverse(int a, int b) {
		Vector vec = new Vector();
		Vector vec2 = new Vector();
		int result = 0;
		if(a > 9) {
			for(int i=a; i <= b; i++) {
				String x=i+"";
				for(int j = 1; j < x.length();j++) {
					int status = 0;
					String p =(x.substring(j,x.length()))+x.substring(0,j);
					int num2 = Integer.parseInt(p);
					if(i!=num2 && num2 <= b && num2 >=a) {
						//System.out.println("P VALUE >> " + p);
						//System.out.println("INDEX OF"+x+" : "+vec.indexOf(x));
						for(int k = 0; k < vec.size(); k++) {
							String tmp = (String) vec.elementAt(k);
							String tmp2 = (String) vec2.elementAt(k);
							int c = Integer.parseInt(tmp);
							int d = Integer.parseInt(tmp2);
							if((c == num2 && i == d) || (c==i && d == num2)) {
								status = 1; break;
							}
						}
						if(status == 0) {
							vec.add(x);
							vec2.add(p);
							//System.out.println(">>>"+x+" "+p);
							result++;
						}
					}
				}
			}
		}
		return result;
	}
	
	public static void main(String [] args) {
		File fFile = new File("B.in");
		Scanner scanner = null;
    	try {
    		scanner = new Scanner(new FileReader(fFile));
      		//first use a Scanner to get each line
      		int line = 1;
      		while ( scanner.hasNextLine() ){
        		String name = scanner.nextLine();
        		String []x = name.split(" ");
        		int p1 = Integer.parseInt(x[0]);
        		int p2 = Integer.parseInt(x[1]);
        		System.out.println("Case #"+line+": "+reverse(p1,p2));
        		line++;
      		}
    	}
    	catch(Exception ex) {
    	}
    	finally {
      		scanner.close();
    	}
	}
}