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