#include <iostream>
using namespace std;

int main() {
    int a, b, temp = 0;
    bool need = 1;
    cin >> a >> b;
    while (need) {
        if (a >= b) {
            temp = temp + a / b;
            a = a%b;
        }
        else
        {
            temp = temp + b / a;
            b = b%a;
        }
        if (a == 0 || b == 0) {
            need = 0;
        }
    }
    cout << temp;
    return 0;
}