ENG  RUSTimus Online Judge
Online Judge
Online contests
About Online Judge
Frequently asked questions
Site news
Problem set
Submit solution
Judge status
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests

Ural Championship 2008

About     Problems     Submit solution     Judge status     Standings
Contest is over

A. Lucky Tickets 2008

Time limit: 0.5 second
Memory limit: 64 MB
New tickets were introduced in Yekaterinburg trams. Their numbers don't have leading zeroes; they just go one after another, starting from number one. Some passengers were embarrassed at hearing this news: now they didn't know how to determine whether a ticket was lucky. New versions of the luckiness criterion were discussed in trams, at tram stops, and, of course, at the tram forum on the Web. According to one of the versions, a ticket was considered lucky if no two opposite digits of its number coincided; i.e., didn+1−i for in + 1 − i, where d1d2dn was the number of the ticket.
One of the addicts of the tram forum was a programmer, and he decided to calculate the amount of lucky tickets in a conductor's roll if the number of the first ticket in the roll was a, and the number of the last ticket was b; the tickets in the roll are numbered consecutively.


The input line contains the integers a and b separated by a space (1 ≤ ab ≤ 1018).


Output the amount of lucky tickets in the roll.


1 10
100 2000
Problem Author: Sergey Pupyrev
Problem Source: The 12th Urals Collegiate Programing Championship, March 29, 2008
To submit the solution for this problem go to the Problem set: 1608. Lucky Tickets 2008