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