#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }
long long lcm(long long a, long long b) { return (a * (b / gcd(a, b))); }
int main() {
  long long a, b, ans = 0;
  cin >> a >> b;
  while (a > 1 && b > 1) {
    if (a > b)
      ans += a / b, a = a % b;
    else if (b > a)
      ans += b / a, b = b % a;
    else
      break;
    if (a == 1 || b == 1) break;
  }
  if (a == 1 || b == 1) ans += a * b;
  if (a == b) ans++;
  cout << ans << endl;
  return 0;
}
