#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a, b, t, ans = 0, a1, b1;
  cin >> a1 >> b1;
  a = min(a1, b1);
  b = max(a1, b1);
  while (a) {
    ans += b / a;
    t = b;
    b = a;
    a = t % a;
  }
  cout << ans << endl;
  return 0;
}
