date1 = input()
date2 = input()
"""
判断是否是闰年
"""
def isLeap(year):
if (year%4 == 0 and year%100 != 0) or (year%400 == 0):
return 1
else:
return 0
"""
判断是否是回文数
"""
def isPalindrome(year):
for i in range(4):
if year[7-i] != year[i]:
return 0
return 1
ans = 0
y1 = int(date1[0:4])
y2 = int(date2[0:4])
for year in range(y1, y2+1):
if isLeap(year):
D = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
else:
D = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
y = str(year)
date = int(y + y[::-1])
if(int(date1) <= date <= int(date2) and 0 < (date%10000//100) <= 12 and isPalindrome(str(date)) and date%100 <= D[date%10000//100-1]):
ans = ans + 1;
print(ans)