#include <bits/stdc++.h>
using namespace std;
long long a, b, x, s = 0;
int main() {
  cin >> a >> b;
  while (a != b) {
    s += a / b;
    a = a % b;
    if (a == 0) {
      cout << s;
      return 0;
    } else
      swap(a, b);
  }
  cout << s;
  return 0;
}
