#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, t, ctr = 0;
  cin >> a >> b;
  while (a != b && a && b) {
    ctr += a / b;
    a %= b;
    swap(a, b);
  }
  cout << ctr << "\n";
  return 0;
}
