Problem B. Before first zero

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

Statement

This problem has absolutely no relation to cars and car races.

Consider a sequence Bi defined as follows: First two elements (B1 and B2) are natural numbers whose decimal representations consist of N and M "1" digits correspondingly. Following terms are computed according to the formula: Bi = |Bi − 2 − Bi − 1|.

Your program should find such an element Bk that Bk + 1 = 0 and Bj ≠ 0 for all 1 ≤ j ≤ k.

In the second sample B1 = 11, B2 = 1111, B3 = 1100, B4 = 11, B5 = 1089, B6 = 1078, …, B151 = 11, B152 = 11, B153 = 0, ….

Input file format

Input file contains two natural numbers N and M.

Output file format

Output file should contain a single integer — Bk or 0 if there's no zero term in B series. Note that the value of Bk may be very large.

Constraints

1 ≤ N, M ≤ 106

Sample tests

No. Input file (input.txt) Output file (output.txt)
1
1 1
1
2
2 4
11

0.101s 0.024s 13