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