#include <bits/stdc++.h>
using namespace std;
const int MaxN = 100005;
const int oo = 1000000000;
const long long Base = 1000000007;
typedef long long Tarr[MaxN];
long long a, Res, tmp, b;
int main() {
  cin >> a >> b;
  while (b > 0) {
    Res += a / b;
    tmp = b;
    b = a % b;
    a = tmp;
  }
  cout << Res;
  return 0;
}
