#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, i, a, b, j, pos = 0, neg = 0, flag = 0, temp;
  string st, st2, st3;
  vector<long long int> v2, v;
  long long int ar[100001] = {0};
  cin >> a >> b;
  if (a == 1) {
    cout << b;
    return 0;
  } else if (b == 1) {
    cout << a;
    return 0;
  }
  while (a > 0 && b > 0) {
    if (a == b) {
      a = 0;
      b = 0;
      flag++;
    } else if (a < b) {
      flag += b / a;
      b = b % a;
    } else if (b < a) {
      flag += a / b;
      a = a % b;
    }
  }
  cout << flag;
  return 0;
}
