#include<bits/stdc++.h>
using namespace std;
bool mogaLi[100005]; // 0- ne moga
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;
    }

    long long tek = a + b;
    mogaLi[tek] = true;
    while(tek + a <= l){
        mogaLi[tek + a] = true;
        mogaLi[tek + b] = true;
        tek+=a;
    }
    for(long long i = a + b; i <= l; i++){
        if(mogaLi[i] == false){
            ans++;
            ///cout<<i<<endl;
        }
    }
    cout<<ans<<endl;

}

//l*l + l
