Polish version    English version  
  History of OI -> X OI 2002/2003


 News
 About Olympic
 History of OI
XVII OI 2009/2010
XVI OI 2008/2009
XV OI 2007/2008
XIV OI 2006/2007
XIII OI 2005/2006
XII OI 2004/2005
XI OI 2003/2004
X OI 2002/2003
Schedule
Problems
Stage III - results
Stage II - results
Stage I - results
Stage II
Rules
For contestants
Helpful resources
IX OI 2001/2002
VIII OI 2000/2001
VII OI 1999/2000
VI OI 1998/1999
V OI 1997/1998
IV OI 1996/1997
III OI 1995/1996
II OI 1994/1995
I OI 1993/1994
 OI books
 National team
 Olympic camps
 Photo gallery
 Links
 SIO
 MAIN
X Olympiad in Informatics 2002/2003

Problem: Tiles
Author: Rafal Rusin

Byteasar, a master tiler, and his mate Byteolini renovate a bathroom of the Bytesons. There is to be a decorative, horizontal strip composed of various figured tiles in the bathroom. The strip is to be n tiles wide and one tile high. Mrs Byteson has told Byteolini that the tiles composing the horizontal strip have had to be put to form a pattern recurring every k tiles. As soon as Mrs Byteson has left, Mr Byteson has come and has told Byteolini that the tiles composing the horizontal strip have had to be put to form a pattern recurring every l tiles. Confused Byteolini has come to Byteasar to ask for advice:

"Chief, how should I finally tile? Should the pattern recur every k, or every l tiles?"

"Whatever they say! You have to tile in such a way that the pattern recurs both every k and every l tiles. Moreover you have to use as many different tiles as possible, to make the pattern not too monotonous. Now, stop playing the philosopher and go to work!"

Byteolini has been left completely dizzy. Help him!

Task

Write a program which:
  • reads the numbers n, k and l from the standard input,
  • computes the number of different tiles that are to be used,
  • writes the result to the standard output.

Input

In the standard input there are three integers n, k and l - in the first, second and third line, accordingly. The numbers satisfy the conditions 1 <= n <= 10500, 1 <= k, l <= n. Note: the numbers k and l need not be divisors of n.

Output

Your program should write to the standard output. In the first and only line there should be one integer: the maximal number of different tiles to use to decorate the bathroom with a strip of length n in such a way that the pattern recurs both every k and every l tiles.

Example

For the following input data:
10
5
7
the correct answer is in the following output:
2



Print friendly version