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