#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, cnt = 0;
  cin >> a >> b;
  while (1) {
    if (a == b || a == 0 || b == 0) break;
    if (b > a) swap(a, b);
    cnt += a / b;
    a = a % b;
  }
  cout << cnt << endl;
}
