#include <iostream> #include <stdio.h> #define LL long long using namespace std; int Euclid(int a,int b) { if(!b) return a; return Euclid(b,a%b); } LL x,y,n,m; int c,res; int main() { //freopen("data.txt", "r", stdin); scanf("%d%d",&n,&m); if(n<m) swap(n,m); x=m*(n/Euclid(n,m)); while(n<x) { n++; m++; c++; y=(m*(n/Euclid(n,m))); if(x>y) { x=y; res=c; } } cout<<res; return 0; }