Triangular King#1854

Triangular King

0,5 saniye
256 megabayt
Çok kolay

The white chess king set out on a journey and arrived in a new country. After much wandering, he settled in a country somewhat reminiscent of his homeland. Here is a map of this country:

Here he began to wander the field, moving from one cell to another, but only if they share a common side. One day, while lodging at field , he wondered what was the minimum number of moves needed to reach field . Help the wandering white king solve this pseudo-chess puzzle.

Giriş

The input file contains two positive integers and , each not exceeding 10^6.

Çıktı

Output the minimum number of moves needed for the wandering king to reach field .

Örnekler

Örnek 1

Loading
Loading