#include <bits/stdc++.h>
using namespace std;
const int MaxN = 1e5 + 17;
long long int a, b, Sum;
int main() {
  ios_base ::sync_with_stdio(0);
  cin >> a >> b;
  while (b != 0) {
    long long k = a / b;
    Sum += k;
    a -= (k * b);
    if (b > a) swap(a, b);
  }
  cout << Sum << endl;
  return 0;
}
