#include<bits/stdc++.h>
using namespace std;
bool mogaLi[100005]; // 0- ne moga
queue<long long> daProbvam;
int main(){
    long long a, b, l, ans = 0;
    cin>>a>>b>>l;
    if(a > b) swap(a, b);

    if(a + b >= l){
        cout<<l<<endl;
        return 0;
    }

    ans = (a + b - 1);

    if(a == 1 && b != 1){
        cout<<ans<<endl;
        return 0;
    }

    if(a == 1 && b == 1){
        cout<<ans<<endl;
        return 0;
    }


    daProbvam.push(a + b);
    while(!daProbvam.empty()){
        long long tek = daProbvam.front();
        daProbvam.pop();
        ///cout<<tek<<endl;
        mogaLi[tek] = true;
        if(tek + a <= l) daProbvam.push(tek + a);
        if(tek + b <= l) daProbvam.push(tek + b);
    }
    for(long long i = a + b; i <= l; i++){
        if(mogaLi[i] == false){
            ans++;
            ///cout<<i<<endl;
        }
    }
    cout<<ans<<endl;

}

//l*l + l
