#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 n,m,x,y; int c,res; int main() { //freopen("data.txt", "r", stdin); scanf("%d%d",&n,&m); if(n<m) swap(n,m); y=Euclid(n,m); x=m*(n/y); bool ok=false; while(n<x) { n++; m++; c++; y=Euclid(n,m); if(x>(m*(n/y))) { ok=true; x=m*(n/y); res=c; } if(c>1000 &&!ok) break; } printf("%d",res); return 0; }