#include <bits/stdc++.h>
using namespace std;
long long i, j, k, m, n;
int main() {
  long long sum = 0, a, b;
  scanf("%I64d%I64d", &a, &b);
  while (a != 0 && b != 0) {
    sum += a / b;
    long long dic;
    dic = b;
    b = a % b;
    a = dic;
  }
  printf("%I64d\n", sum);
  return 0;
}
