#include <bits/stdc++.h>
long long int FastPower(int bast, int power);
int main() {
  long long int a, b;
  long long int all = 0;
  scanf("%I64d%I64d", &a, &b);
  while (1) {
    if (a == 1 || b == 1) {
      all += (a == 1 ? b : a);
      break;
    }
    if (a % b == 0) {
      all += a / b;
      break;
    } else if (b % a == 0) {
      all += b / a;
      break;
    }
    if (a > b) {
      all += a / b;
      a = a % b;
    } else if (b > a) {
      all += b / a;
      b = b % a;
    }
  }
  printf("%I64d", all);
  return 0;
}
long long int FastPower(int bast, int power) {
  long long int ans = 1;
  while (power > 0) {
    if (power & 1) {
      ans *= bast;
    }
    bast *= bast;
    power >>= 1;
  }
}
