#include <iostream>
using namespace std;
int main() {
long long int A, B, X = 0;
cin >> A >> B;
while(A != 0 && B != 0) {
if(A > B) {
A = A % B;
X += B / A;
} else {
B = B % A;
X += A / B;
}
}
cout << X;
return 0;
}
mas = []
for i in range(4):
num = int(input())
mas.append(num)
print(min(mas))
<br/>