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