#include<bits/stdc++.h> usingnamespace std; typedeflonglong lnt; template <classT> inlinevoidread(T &x){ x = 0; int c = getchar(), f = 1; for (; !isdigit(c); c = getchar()) if (c == 45) f = -1; for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0'); } lnt f(lnt a, lnt b, lnt c, lnt n){ if (!c) return0; if (a >= c || b >= c) return a/c*n*(n+1)/2+b/c*(n+1)+f(a%c, b%c, c, n); return (a*n+b)/c*n-f(c, c-b-1, a, (a*n+b)/c-1); } intmain(){ lnt a, b, c; read(a), read(b), read(c); returnprintf("%lld\n", f(a, c%a, b, c/a)+c/a+1), 0; }