This page is still under construction.

Parts of this page are still being built. What you see may change.

Minimizing the LCM

Time limit1sMemory limit256 MB

Summary
Find the smallest N of at least 1 that minimizes the least common multiple of A+N and B+N.
Level

Medium6 of 10

Topics
Number theory, Math
Solved
No attempts yet

Problem

You are given two natural numbers AA and BB. Find the natural number NN that makes the least common multiple of A+NA + N and B+NB + N as small as possible.

Input

The first line contains two natural numbers AA and BB, separated by a space. 1≤A,B≤1091 \le A, B \le 10^9.

Output

Print NN on the first line. If several values of NN make the least common multiple minimal, print the smallest one.

Note

A natural number is an integer of at least 1, so N≥1N \ge 1.

Examples2

  1. Example 1

    Input
    4 10
    
    Expected output
    2
    
  2. Example 2

    Input
    6 15
    
    Expected output
    3