favorite We need a little bit of your help to keep things running, click on this banner to learn more

Summer School 2011 in Sevastopol, Day 3

Divisibility by 4

Let aninfinitesequence of numbers, composedas follows:

A0 = 1, A1 = 12,…,A9 = 12345678910, A10 = 1234567891011, ….

That is,each successive termis obtainedby assigningthe sequenceat the endof the previous memberfor decimalnumbers,one greater than thevalue of the indexof theterm of the sequence.

It is necessaryto determine the totalnumber of membersof thesequences thatwithout the restare divisible by 4, among thosewhose indexbelongs to thesegment [m, n], where 0mn1018.


The onlyline of the inputfileare given twonon-negative integersm and n.


The onlyline ofthe output filea single integer- the answerof the problem.

Time limit 1 second
Memory limit 64 MiB
Input example #1
0 0
Output example #1