#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a, c, b, ans = 0;
  cin >> a >> b;
  while (b > 0) {
    ans += a / b;
    a %= b;
    c = b;
    b = a;
    a = c;
  }
  cout << ans;
}
