Problem H. Honest mileage

Author:I. Oleynikov   Time limit:1 sec
Input file:input.txt   Memory limit:256 Mb
Output file:output.txt  

Statement

Serge is an auto dealer. He brings cars from Japan and sells them in Russia. In contrast to a widespread practice of "rolling back" mileage to make a car look less used, Serge prefers a honest approach. He even drives his cars a little to get a "nice-looking" mileage numbers.

Serge says that mileage is "nice-looking" if digits located at corresponding positions on main and auxiliary car odometers are equal. The numbers on the main and auxiliary odometer written one below another look like this:

00015153 0
XXXX5121.0

Dot is the decimal separator on auxiliary odometer and does not take a place of a digit. "X" is a space filler, designating that there is no digit on this place.

Main odometer is incremented by one after each full kilometer since the moment when Serge starts driving. Serge may reset auxiliary odometer to zero at any time. Auxiliary odometer is incremented by 0.1 after each full hundred of meters since either the moment when Serge starts driving or last reset, whichever is later. Whenever any odometer reaches maximum value, it resets to zero upon next increment.

Your program must calculate a minimum distance that Serge needs to drive on his car to set car odometers to a nice-looking mileage. In the example above Serge needs to drive 35.5 km.

Input file format

The input file contains two strings, one per line. The first string contains nine digits and determines initial state of main odometer.

The second string contains four 'X' characters followed be four decimal digits, dot and another digit — the state of auxiliary odometer.

Output file format

Output file must contain a single exact floating point number — the distance that Serge must drive, measured in kilometers.

Sample tests

No. Input file (input.txt) Output file (output.txt)
1
000151530
XXXX5121.0
35.5

0.078s 0.015s 13