#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long int counter = 0, a, b, t;
  cin >> a >> b;
  while (true) {
    if (b > a) {
      t = a;
      a = b;
      b = t;
    }
    counter = counter + (a / b);
    a = (a % b);
    if (a == 0) break;
  }
  cout << counter;
  return 0;
}
