#include <bits/stdc++.h>
const int inf = 1500000000;
const int d = 1e9 + 7;
using namespace std;
long long int solve(long long int a, long long int b) {
  long long int A = max(a, b);
  long long int B = min(a, b);
  if (A % B == 0) return A / B;
  return (solve(B, A % B) + A / B);
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t = 1;
  while (t--) {
    long long int a, b;
    cin >> a >> b;
    cout << solve(a, b);
  }
  return 0;
}
