#include <bits/stdc++.h>
using namespace std;
int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }
int LCD(int a, int b) { return (a * b) / GCD(a, b); }
int MyPow(int a, int b) {
  int res = 1;
  for (int(i) = (1); i <= (b); i += (1)) res *= a;
  return res;
}
int main() {
  int64_t a, b, res = 0, c, c1;
  cin >> a >> b;
  c = a;
  c1 = b;
  while (c % c1 != 0) {
    if (a > b) {
      res += a / b;
      a = a % b;
    } else {
      res += b / a;
      b = b % a;
    }
    if (a > b) {
      c = a;
      c1 = b;
    } else {
      c = b;
      c1 = a;
    }
  }
  res += c / c1;
  cout << res;
}
