#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T abs(T t) {
  return t < 0 ? -t : t;
}
const unsigned long long modn = 1000000007;
inline unsigned long long mod(unsigned long long x) { return x % modn; }
int main() {
  long long a, b;
  scanf("%lld %lld", &a, &b);
  long long ans = 0;
  while (42) {
    ans += a / b;
    if (a % b == 0) break;
    long long aa = b;
    long long bb = a % b;
    a = aa;
    b = bb;
  }
  printf("%lld\n", ans);
  return 0;
}
