#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int m, n;
  cin >> m >> n;
  long long int s = 0;
  do {
    if (m == n) {
      s += 1;
      break;
    }
    if (m > n) {
      s += m / n;
      m = m % n;
    } else {
      s += n / m;
      n = n % m;
    }
  } while (m != 0 && n != 0);
  cout << s << endl;
  return 0;
}
