#include <bits/stdc++.h>
using namespace std;
long long int a, b, ans;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> a >> b;
  if (b == 1) {
    cout << a;
    return 0;
  }
  if (a % b == 0) {
    cout << a / b;
    return 0;
  }
  while (b >= 1) {
    ans += a / b;
    a = a % b;
    if (b > a) swap(a, b);
  }
  cout << ans;
  return 0;
}
