//每次枚举前四位,把前四位反转拼接到后面去,这样就是在回文数里判断一个数是不是合法日期
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main{
static int n,m,res;
static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
//这里要从0开始,才会跟月份对应
static int[] days = {0,31,28,31,30,31,30,31,31,30,31,30,31};
public static void main(String[] args)throws IOException {
n = Integer.parseInt(in.readLine());
m = Integer.parseInt(in.readLine());
//只枚举前四位
for (int i = 1000; i < 9999; i++) {
int x = i,t = i;
//将前四位反转拼接
for (int j = 0; j < 4; j++) {
x = x * 10 + t % 10;
t /= 10;
}
//合法日期并且符合题意就算一个答案
if (x >= n && x <= m && check(x)) res++;
}
System.out.println(res);
in.close();
}
//判断日期合法
public static boolean check(int date){
int year = date / 10000; //丢掉后面四位
int month = date / 100 % 100; //丢掉后面两位拿到后面两位
int day = date % 100; //拿到后面两位
//先判断月,再判断日,判断日的时候先不判断2月,2月单独判断
if (month == 0 || month > 12) return false;
if (day == 0 || (month != 2 &&day > days[month]))return false;
//月份为2单独判断
if (month == 2){
int etra = 0;
if (year % 400 == 0 || year % 4 == 0 && year % 100 != 0) etra++;
if (day > 28 + etra) return false;
}
return true;
}
}