ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

2177. Vadim and Sudoku: XV-Pairs

Time limit: 1.0 second
Memory limit: 256 MB
This time, Vadim decided to try creating his own Sudoku with a different unusual rule. Two numbers are considered an XV-pair if their sum equals either X or V.
Vadim wants to create a sequence of positive integers where every two adjacent numbers form an XV-pair. Since this sequence will be part of his Sudoku, the numbers in it must not repeat. Help him find the maximum number of numbers that can be in this sequence.

Input

The first line contains an integer X (3 ≤ X ≤ 109).
The second line contains an integer V (3 ≤ V ≤ 109).

Output

Output the maximum length of a sequence of distinct positive integers in which every two adjacent numbers form an XV-pair.

Sample

inputoutput
10
5
4

Notes

In the example, a suitable sequence could be [8,2,3,7].
Problem Author: Vadim Barinov
Problem Source: Ural School Programming Contest 2023