#include <bits/stdc++.h>
using namespace std;
void solve();
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}
void solve() {
  long long a, b;
  cin >> a >> b;
  long long ct = 0;
  while (a > 0 && b > 0) {
    if (a > b) {
      ct += a / b;
      a = a % b;
    } else {
      ct += b / a;
      b = b % a;
    }
  }
  cout << ct;
}
