#include <bits/stdc++.h>
int main() {
  unsigned long long int a, b, t = 1, c, x;
  int i;
  scanf("%llu %llu", &a, &b);
  c = 0;
  while (b != 0) {
    c += a / b;
    if (a % b < b) {
      t = a;
      a = b;
      b = t % b;
    } else {
      a = a % b;
    }
  }
  printf("%llu\n", c);
  return 0;
}
