Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

La Casa De POI

Limits: 1s, 512 MB

“You are being watched. The government has a secret system: a machine that spies on you every hour of every day. I know, because I built it. I designed the machine to detect acts of terror, but it sees everything. Violent crimes involving ordinary people; people like you. Crimes the government considered ‘irrelevant’. They wouldn’t act, so I decided I would. But I needed a partner, someone with the skills to intervene. Hunted by the authorities, we work in secret. You’ll never find us, but victim or perpetrator, if your number’s up… we’ll find you.”, - these are the words of Harold Finch, a reclusive billionaire software genius who teamed up with John Reese, a former Special Forces soldier and CIA operative.

Thanks to The Machine created by Finch, they obtain a Social Security number of a person of interest, with no idea whether the person is a perpetrator or victim in a crime that is about to happen. Finch and Reese then attempt to understand the case and stop the crime from occurring.

Meanwhile, a mysterious man, known as “The Professor”, is planning the biggest bank heist in history. To carry out the ambitious plan, he recruits a team of eight people with certain abilities who have nothing to lose. The goal is to enter the Shikkha Shakha of RUET (Rajshahi University of Euro and Transactions), also known as the Fortress of Printers, and print €2.4 billion. To do this, the team requires eleven days of seclusion, during which they have to deal with elite police forces and 67 hostages.

The Machine gave Finch and Reese the social security number of The Professor so that they can prevent the death of a certain member of the money heist team, someone very dear to The Professor. But being a very cautious person, The Professor laid a lot of traps so that no one can find the identities of these robbers. At one point while solving this complex case, Reese needed to find the password to a computer system. Root, a genius hacker, felt like helping out and gave Reese two numbers N and M

To find the password, Reese has to find the common divisors of N and M. Because, the summation of these common divisors is the password. You have to help Reese find this password.

Input

Given two integers N (1 ≤ N ≤ 1012) and M (1 ≤ M ≤ 1012), find the summation of all the numbers that divides both N and M without any remainder i.e. find the summation of the common divisors of N and M.

Output

Print the summation of the common divisors of N and M in a single line.

Samples

InputOutput
6 3
4

Author
Discussion
Submit

Login to submit