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