#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b;
  cin >> a >> b;
  long long total = 0;
  while (b != 0) {
    total += a / b;
    a = a % b;
    if (b > a) {
      long long t = a;
      a = b;
      b = t;
    }
  }
  cout << total << "\n";
}
