#include<bits/stdc++.h>
using namespace std;
int main(){
long long n1,n2,k;
char c1,c2;
cin>>n1>>c1;
cin>>n2>>c2;
cin>>k;
if(k>n1){
    if(k-n1<n2){
        if(k==0)
            cout<<n1;
        else
            cout<<n1+(k-n2);
    }
    else{
        cout<<(k-n1)+n2;
        return 0;
 }
}
else if(k>n2)
    if(k-n2<n1){
        k=k-n2;
        if(k==0)
            cout<<n2;
        else
            cout<<k;
    }
    else{
        cout<<(k-n2)+n1;
        return 0;
 }
else{
    cout<<k;
    return 0;
}




return 0;
}
