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 NN and MM.

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

Input

Given two integers NN (1N10121 ≤ N ≤ 10^{12}) and MM (1M10121 ≤ M ≤ 10^{12}), find the summation of all the numbers that divides both NN and MM without any remainder i.e. find the summation of the common divisors of NN and MM.

Output

Print the summation of the common divisors of NN and MM in a single line.

Sample

InputOutput
6 3
4

Submit

Login to submit.

Statistics

71% Solution Ratio
smile_Earliest, Aug '19
N4zmusSakibFastest, 0.0s
JIANEELightest, 5.5 kB
Daiyan_DahyShortest, 239B
Toph uses cookies. By continuing you agree to our Cookie Policy.