#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b;
  cin >> a >> b;
  long long ans = 1;
  a -= b;
  while (a != 0 && b != 0) {
    if (max(a, b) == a) {
      ans += (a / b);
      a = a % b;
    } else if (max(a, b) == b) {
      ans += (b / a);
      b = b % a;
    }
  }
  cout << ans << endl;
}
