Beaver School in Lviv#4546

Beaver School in Lviv

1 second
128 megabytes
Medium

The historical center of Lviv is listed in the UNESCO World Heritage Site. The city has the largest number of architectural monuments in Ukraine. In 2009, Lviv was awarded the title of Cultural Capital of Ukraine. The city periodically takes leading places in the ratings of tourist and investment attractiveness.

prb4546

It is in this beautiful city and right now, from October 27 till November 2, 2013, the first All-Ukrainian school for programming takes place within the framework of the Beaver International Competition in Informatics and Computer Skills.

During the intellectual games of the Beaver school, the participants were given the following task: from the number get the number using the minimum number of the following operations:

Input

Three positive integers , , (m, n \le 100000, 0 < t < 10).

Output

Print the smallest number of operations to get from .

Examples

Example 1

Loading
Loading