Two dimensional arrays


Once the pupils of the B-th school of city G decided to go to cinema. Cinema Administration has placed them in the hall of size n × m, which has been specially selected so that all the seats were occupied by pupils. Each cinema visitor was given a number.

Pupils took their places in the following way: they entered the hall in the order of their numbers, and fully occupied initially the first row, then second row, then third row, etc.


However the class teacher decided that such seating is bad for the behavior of pupils and replaced them in another way: the pupils first occupied all the first places of each row, then all the second places in each row, etc. (see picture).


The administration has decided to find out how many pupils do not change their place after replacement.


First line contains numbers n and m (1n, m1000).


Print the number of pupils whose seat was not changed after replacement.

Time limit 1 second
Memory limit 128 MiB
Input example #1
3 3
Output example #1
Input example #2
3 4
Output example #2