#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long int x, y, result = 0, tmp;
  cin >> x >> y;
  do {
    result += x / y;
    x = x % y;
    tmp = y;
    y = x;
    x = tmp;
  } while (x != 0 && y != 0);
  cout << result << endl;
  return 0;
}
