#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, mx = 0, c = 0;
  cin >> a >> b;
  if (b == 1) {
    cout << a << endl;
    return 0;
  }
  while (true) {
    long long d = a / b;
    long long z = b;
    b = a - (b * d);
    a = z;
    a = max(a, b);
    b = min(a, b);
    c += d;
    if (b == 0) {
      break;
    }
  }
  cout << c << endl;
  return 0;
}
