题目:http://codeforces.com/contest/344/problem/C
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long LL;
LL a,b;
int main()
{
cin>>a>>b;
if(a>b) swap(a,b);
LL ans = 0;
while(b)
{
ans += a/b;
a %= b;
swap(a,b);
}
cout<<ans<<endl;
return 0;
}