#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b;
  cin >> a >> b;
  long long ans = 0;
  while (true) {
    long long x = max(a, b);
    long long y = min(a, b);
    if (x == 0 || y == 0) break;
    long long n = x / y;
    ans += n;
    x -= n * y;
    a = x;
    b = y;
  }
  cout << ans;
  return 0;
}
