#include <bits/stdc++.h>
int main() {
  long long a, b, temp;
  long long ans;
  while (scanf("%I64d%I64d", &a, &b) != EOF) {
    if (a > b) {
      temp = b;
      b = a;
      a = temp;
    }
    ans = 0;
    while (a >= 1 && b >= 1) {
      ans += b / a;
      temp = a;
      a = b - (b / a) * a;
      b = temp;
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
