#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b;
  long long out = 0;
  scanf("%I64d %I64d", &a, &b);
  while (b > 1) {
    out += a / b;
    a = a % b;
    if (a == 0) break;
    if (a < b)
      swap(a, b);
    else
      break;
  }
  if (a < b && a != 0) swap(a, b);
  if (a == b)
    out++;
  else {
    out += a;
  }
  printf("%I64d\n", out);
  return 0;
}
