atcoder#ARC145B. [ARC145B] AB Game

[ARC145B] AB Game

Score : 500500 points

Problem Statement

The following game is called Game nn:

The game is played by Alice and Bob. Initially, there are nn stones.

The players alternate turns, making a move described below, with Alice going first. The player who becomes unable to make a move loses.

  • In Alice's turn, she must remove a number of stones that is a positive multiple of AA.
  • In Bob's turn, he must remove a number of stones that is a positive multiple of BB.

In how many of Game 11, Game 22, ..., Game NN does Alice win when both players play optimally?

Constraints

  • 1N,A,B10181 \leq N ,A,B \leq 10^{18}
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN AA BB

Output

Print the answer.

4 2 1
2

In Game 11, Alice cannot make a move and thus loses.

In Game 22, Alice removes 22 stones, and then Bob cannot make a move: Alice wins.

In Game 33, Alice removes 22 stones, Bob removes 11 stone, and then Alice cannot make a move and loses.

In Game 44, Alice removes 2×2=42 \times 2 = 4 stones, and then Bob cannot make a move: Alice wins.

Therefore, Alice wins in two of the four games.

27182818284 59045 23356
10752495144