#include<iostream>
using namespace std;
int main(){
    long long n,k,t;
    cin>>n>>k>>t;
    if(t<k+1){
        cout<<t<<endl;
    }
    if(t>k && t<n+1){
        cout<<k<<endl;
    }
    if(t>n){
        cout<<k+n-t<<endl;
    }
    return 0;
    }

#include <iostream>

using namespace std;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n,k,t;
	cin >> n >> k >> t;
	if(t >= k && t <= n) cout << k;
	else if(t > n) cout << k - t + n;
	else cout << t;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long n,k,t;
    cin>>n>>k>>t;
        if(t>(k+n))
        t=t-(n+k)*(t/(n+k));
    if(t<=k)
        cout<<t;
    else
        if(t<=n)
            cout<<k;
        else
            cout<<(n+k)-t;
    return 0;
}

#include <iostream>

using namespace std;

int main()
{
    int n, k, t;
    cin>> n;
    cin>> k;
    cin>> t;
    if (t<=k)
        cout<< t;
    else if (t<=n)
        cout<< k;
    else
        cout<< k-t+n;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << min({b, c, b - c + a});
}

#include <bits/stdc++.h>

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (c > a) c = b - c + a;
  cout << min(b, c);
}

#include<iostream>
#include<stdio.h>
#include<string.h>
#include<string>
#include<cmath>
#include<math.h>
#include<map>
using namespace std;
typedef long long ll;
int main()
{
	int n, k, t;
	int ans = 0;
	cin >> n >> k >> t;
	if (t >= k&&t <= n)
		ans = k;
	else if (t < k)
		ans = t;
	else if (t > n)
		ans = k - t + n;
	cout << ans << endl;
	return 0;
}

// random_shuffle example
#include <iostream>     // std::cout
#include <algorithm>    // std::random_shuffle
#include <vector>       // std::vector
#include <ctime>        // std::time
#include <cstdlib>
#include <math.h>
    // std::rand, std::srand
using namespace std;
// random generator function:
int myrandom (int i) { return std::rand()%i;}
int p[1010];
int f[1010];
vector< pair<int, int> > v;
long double dist(int a, int b, int c ,int d){
	return sqrt( (a - c) * (a - c)*1.0 + (b - d)*(b - d)*1.0 );
}
long double d_f;
long double d_s;
int main () {

    int n, k, t; cin >> n >> k >> t;
    int ans = k;
    if(t < k) ans = t;
    if(t > n) ans -= (t-n);
    cout << ans << endl;

	return 0;
}

/*
 	int a1,b1, a2,b2, a3, b3;
	cin>>a1>>b1>>a2>>b2>>a3>>b3;

	//first case
	d_f = dist( a1, b1, a2, b2);
	d_s = dist( a2, b2, a3, b3);
	if(d_f == d_s){
		long double d1 = dist( a1, b1, a3, b3)/2.0;
		//a and c
		long double m = (b3 - b1)/(a3 - a1);
		long double b = b1 - m*a1;
		long double A = m, B = -1, C = b;
		long double x = abs( A*a2 + B*b2 + C)/ sqrt(A*A +B*B);
		double w =  d_f*d_f;
		double h = d1*d1 + x*x;
		if(w == h)
			{cout<< "yes"; return 0;}
	}
	cout<<"No\n";

	return 0;
}
	*/

#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,k,t;
    cin>>n>>k>>t;
    if(t<k && t>=0){
        cout<<t<<endl;
    }
    else if(t>=k && t<=n){
        cout<<k<<endl;
    }
    else if(n+k>=t){
            cout<<n+k-t<<endl;
    }
    else
        cout<<"0";
    return 0;
}

#include <bits/stdc++.h>
#define ll             long long
#define f(i,a,b)       for(int i=(a);i<(b);i++)
#define fd(i,a,b)      for(ll i=(a);i>(b);i--)
#define x              first
#define y              second
#define si(a)          scanf("%d",&a)
#define sii(a,b)       scanf("%d %d",&a,&b)
#define siii(a,b,c)    scanf("%d %d %d",&a,&b,&c)
#define sl(a)          scanf("%I64d",&a)
#define sll(a,b)       scanf("%I64d %I64d",&a,&b)
#define slll(a,b,c)    scanf("%I64d %I64d %I64d",&a,&b,&c);
#define pfci(n,ans)    printf("Case %I64d: %d\n",n,ans)
#define pfcl(n,ans)    printf("Case %I64d: %I64d\n",n,ans)
#define pfcd(n,ans)    printf("Case %I64d: %lf\n",n,ans)
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define MOD 1000000009
#define ld long double
#define mp make_pair
using namespace std;
#define INF 1e12
#define EPS 1e-7

int main()
{
    ll n,k,t;
    cin>>n>>k>>t;
    if(t<=k) cout<<t<<endl;
    else if(t<=n) cout<<k<<endl;
    else if(t<=n+k) cout<<(n+k)-t<<endl;
    else cout<<"0"<<endl;
}

#include <cstdio>
#include <iostream>
#include <algorithm>
int N,K,T;
int main(){
	std::cin>>N>>K>>T;
	if(T<=K)std::cout<<T;
	if(T>K&&T<=N)std::cout<<K;
	if(T>N)std::cout<<N+K-T;
}

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MAXV = (1ll<<32);

int main() {
    ll n,k,t;
    cin>>n>>k>>t;
    if(t<k)
    {
        cout<<t<<endl;
    }
    else if(t>n)
    {
        cout<<(n-t+k)%k<<endl;
    }
    else
    {
        cout<<k<<endl;
    }

    return 0;
}

#include <iostream>

using namespace std;

int main() {
    int n, k, t;
    cin >> n >> k >> t;

    int res = k - (t - n);
    if (res > k) res = k;
    if (res > t) res = t;

    cout << res;
    return 0;
}

#include <iostream>
using namespace std;
int main()
{
	int a , b , c ;
	cin >> a >> b >> c ;
	if(c<=b)
	cout<<c;
	else if(c>b && c<=a)
	cout<<b;
	else if(c>b && c>a)
	cout<<b-(c-a);
}

//dont give up
#include<bits/stdc++.h>
using namespace std;
#define    ll    long long int
#define pi              2*acos(0.0)
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        (a*b)/gcd(a,b)
map<ll,ll>mp,mk;
set<ll> s1,s2;
vector<ll> v,w;
ll a[2000006],b[2000006];
string s="",p="",q="";
char ch;
ll m,n,c,d,i,j,k,l,r,x,t,y,u,e,f,g,h;
int main()
{
    cin>>n>>k>>t;
    m=min(k,min(t,n-t+k));
    cout<<m;
}

#include <stdio.h>

void main() {
	int n, k, t;
	scanf("%d%d%d", &n, &k, &t);
	if (t >= k && t <= n)
		printf("%d", k);
	if(t < k)
		printf("%d", t);
	if (t > n)
		printf("%d", n + k - t);
}

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void solve()
{
    ll n,k,t;
    cin>>n>>k>>t;
    if(t<=k){
        cout<<t<<endl;return;
    }
    if(t>k&&t<=n){
        cout<<k<<endl;return;
    }
    cout<<k-(t-n)<<endl;return;
}
int main()
{
    solve();
}

#include <iostream>
#include <string>
using namespace std;
int main()
{
    int n,k,t;
    cin>>n>>k>>t;
    if (t<=n&&t>=k)
    cout<<k<<endl;
    if (t<k)
    cout<<t;
    if (t>n)
    cout<<(k-(t-n));
  return 0;
}

#include<bits/stdc++.h>
using namespace std;

int n,k,t;

int main()
{
	cin>>n>>k>>t;
	if(t<=k)cout<<t;
	else if(t<=n)cout<<k;
	else cout<<k-t+n;

	return 0;
}

# include<iostream>
using namespace std;
long long n, k, t;
int main()
{
	cin >> n >> k >> t;
	int a = n / k;
	int b = a * k;
	if (t <= k)
		cout << t << endl;
	else if (t > k && t <= n)
	{
		cout << k;
	}

	else {
		int ans = k - t + n;
		if (ans >= 0) cout << ans << endl;
		else cout << 0 << endl;
	}
}

#include <bits/stdc++.h>
#define ll long long
#define fr(l,r) for(ll int i=l;i<r;i++)
#define srt(arr) sort(arr.begin(),arr.end())
#define mp make_pair
#define pb push_back
using namespace std;

int main() {
    ll int n,k,t;cin>>n>>k>>t;
    //vector <bool> arr(n);
    ll int c=0;
    if(t<=k)
        c=t;
    else if(t>k && t<=n)
        c=k;
    else
        c=n+k-t;

    cout<<c;

    return 0;
}

#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
	long long int n,k,t;
	cin >> n >> k >> t;
	if(t <= k)
		cout << t;
	else if(t <= n)
		cout << k;
	else
		cout << k - (t - n);
	return 0;
}

#pragma GCC optimize("trapv")
#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#pragma GCC target ("avx2")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define forceRTE cout<<1/0
#define forceTLE while(true){}
#define ll long long
#define ld long double
#define gtl getline
#define vec vector
#define ar array
#define umap unordered_map
#define pq priority_queue
#define pqintasc priority_queue<int,vector<int>,greater<int> >
#define pqpairasc priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > >
#define map_set(ptr,sz) ptr.reserve(sz),ptr.max_load_factor(0.25);
#define FOR(a,b,c) for(int i=a;i<b;i+=c)
#define EACH(x,a) for(auto x:a)
#define debug(x) send("Debug: ",x," ",double(measurer*1.0/CLOCKS_PER_SEC),"\n");
#define len(ds) int(ds.size())
using namespace std;
using namespace __gnu_pbds;
time_t measurer=clock();
const int MAXN = 1000001;
const int MOD = 1000000007;
const int MOD2 = 998244353;
const bool DEBUG = false;
double exe_time = 0.0;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> policytree;
class mnlib{
    public:
    class VectorOperations{
        public:
        int distinctelements(vector<ll> v){
            set<ll>s;
            EACH(x,v){
                s.insert(x);
            }
            return int(len(s));
        }
    } vcs;
    class StringOperations{
        public:
        int hamDist(string a,string b){
            int qq = 0;
            for(int i=0;i<len(a);i++)
                qq+=(a[i]!=b[i]);
            return qq;
        }
    } sop;
    class Geometry{
        public:
        long double tangent(double x){
            return tan(x*3.141592653589793/180);
        }
        long double sine(double x){
            return sin(x*3.141592653589793/180);
        }
        long double cosine(double x){
            return cos(x*3.141592653589793/180);
        }
        long double arcsin(double x){
            return asin(x)/3.141592653589793*180;
        }
        long double arccos(double x){
            return acos(x)/3.141592653589793*180;
        }
        long double arctan(double x){
            return atan(x)/3.141592653589793*180;
        }
        long double area(long long n,long double s){
            long double ans=s*s*n;
            ans=ans*1.0/(4*tangent(180.0/n));
        }
        long double areaTriangle(long double a,long double b,long double c){
            long double ans=0.5*a*b*sine(c);
        }
    } geo;
    class Primes{
        public:
        bool checkPrime[MAXN+1];
        void initprimes(){
            for(int i=1;i<=MAXN;i++)checkPrime[i]=true;
            checkPrime[1]=false;
            for(int i=2;i*i<=MAXN;i++){
                if(checkPrime[i]){
                    for(int j=i*i;j<=MAXN;j+=i) checkPrime[j]=false;
                }
            }
        }
        bool isPrime(int x){ return checkPrime[x]; }
    } prm;
    class segmentTree{
        public:
        ll rmq[4*MAXN];
        void initrmq(){ FOR(0,4*MAXN,1) rmq[i]=0;}
        void updrmq(int le, int ri, int indx, int ptr,ll ele){
            if(le==ri){rmq[ptr]=ele; return;}
            if(indx<=(le+ri)/2) updrmq(le,(le+ri)/2,indx,2*ptr+1,ele);
            else updrmq((le+ri)/2+1,ri,indx,2*ptr+2,ele);
            rmq[ptr]=min(rmq[2*ptr+1],rmq[2*ptr+2]);
        }
        ll queryrmq(int le, int ri, int ptr, int lw, int rw){
            if(lw>ri || rw<le) return LLONG_MAX;
            else if(lw<=le && ri<=rw) return rmq[ptr];
            return min(queryrmq(le,(le+ri)/2,ptr*2+1,lw,rw),queryrmq((le+ri)/2+1,ri,ptr*2+2,lw,rw));
        }
        void updallrmq(ll x[],int lens){
            FOR(0,lens,1) updrmq(0,MAXN-1,i,0,x[i]);
        }
    } segt;
} lib;
void read(){}
template<typename R, typename... P> void read(R& Rz, P&... Pz){
    cin >> Rz;
    read(Pz...);
}
template<typename QwQ> void read(vec<QwQ>&Rz){
    int l=len(Rz);
    for(int i=0;i<l;i++){
        QwQ R2;
        read(R2);
        Rz[i]=R2;
    }
}
void send(){}
template<typename G, typename... M> void send(G Gz, M... Mz){
    cout << Gz;
    fflush(stdout);
    send(Mz...);
}
template<typename UwU> void send(vec<UwU>Rz){
    for(int i=0;i<len(Rz);i++){
        send(Rz[i]);
        if(i+1<Rz.size())send(' ');
    }
    send("\n");
}
template<typename Z, typename Z2> void init(vec<Z>&Rz, Z2 OO){
    for(int i=0;i<len(Rz);i++){
        Rz[i]=OO;
    }
}
mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());
void prep_room(){
    lib.prm.initprimes();
    lib.segt.initrmq();
}
void open_debug(){
    send(exe_time);
}
void solve(){
    ll n,k,t;
    read(n,k,t);
    if(1<=t&&t<=k){
        send(t);
    }
    else if(n+1<=t&&t<=n+k){
        send(n+k-t);
    }
    else{
        send(k);
    }
}
main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    prep_room();
    int T=1;//read(T);
    while(T--)solve();
    measurer=clock()-measurer;
    exe_time = double(measurer*1.0/CLOCKS_PER_SEC);
    if(DEBUG)open_debug();
}

/*****************************
    * Author: Mahfuz *
  * Created: 19.09.2020 *
*****************************/

#include <bits/stdc++.h>

#define PI 3.141592653589793238462
#define ll long long
#define ld long double

using namespace std;

int main()
{

  ll int n, k, t;

  cin >> n >> k >> t;

  if(t <= k)
  {
    cout << t << endl;
  }
  else if(t>k && t <= n)
  {
    cout << t - (t-k) << endl;
  }
  else
  {
    cout << ((n+k) - t) << endl;
  }

  return 0;
}

/*****************************
    * Author: Mahfuz *
  * Created: 19.09.2020 *
*****************************/

#include <bits/stdc++.h>

#define PI 3.141592653589793238462
#define ll long long
#define ld long double

using namespace std;

int main()
{

  ll int n, k, t;

  cin >> n >> k >> t;

  if(t <= k)
  {
    cout << t << endl;
  }
  else if(t>k && t < n)
  {
    cout << t - (t-k) << endl;
  }
  else if(t == n)
  {
    cout << t - (n-k) << endl;
  }
  else
  {
    cout << ((n+k) - t) << endl;
  }

  return 0;
}

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
	long int n, k, t;
	cin >> n >> k >> t;

	if(t <= k) {
		cout << t << endl;
	}else if(t > k && t <= n) {
		cout << k << endl;
	}else if(t > n && t < n+k)
	    cout << n+k-t << endl;

	return 0;
}

#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
int main(){
    int n,k,t;
    while(~scanf("%d%d%d",&n,&k,&t)){
        if(t<=k) printf("%d\n",t);
        else if(t<=n) printf("%d\n",k);
        else printf("%d\n",n+k-t);
    }
return 0;}

#include <iostream>
#include <algorithm>
using namespace std;
int n, k, t;
int main()
{
	cin >> n >> k >> t;
	if (t <= n)
		cout << min(t, k) << endl;
	else
		cout << max(0, (k - (t%n))) << endl;
//	system("pause");
	return 0;
}

#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
/*
	At time 1, the first spectator stands.
	At time 2, the second spectator stands.
	...
	At time k, the k-th spectator stands.
	At time k + 1, the (k + 1)-th spectator stands and the first spectator sits.
	At time k + 2, the (k + 2)-th spectator stands and the second spectator sits.
	...
	At time n, the n-th spectator stands and the (n - k)-th spectator sits.
	At time n + 1, the (n + 1 - k)-th spectator sits.
	...
	At time n + k, the n-th spectator sits.
*/
int main() {
	int n, k, T;
	cin >> n >> k >> T;
	if (T >= 0 && T <= k) {
		cout << T;
	}
	else if (T > k && T < n) {
		cout << k;
	}
	else if (T >= n && T <= n + k) {
		cout << n - (T - k);
	}

	/*
	int n, k, T, i = 0, t = -1, spectators = -1;
	cin >> n >> k >> T;
	while (i <= n + k) {
		if (t < k) {
			t++;
			spectators++;
			// cout << t << " " << spectators << endl;
		}
		else if (t >= k && t < n) {
			t++;
			// cout << t << " " << spectators << endl;
		}
		else if (t >= n && t <= n + k) {
			t++;
			spectators--;
			// cout << t << " " << spectators << endl;
		}
		if (T == t) {
			cout <<  spectators;
			break;
		}
		i++;
	}*/

	/*int n, k, T;
	char wave;
	cin >> n >> k >> T;
	int t = 0;
	while (t <= n + k) {

		int count = t, end = 1, spectators = 0, temp = 0;
		int j = 1;
		// cout << "At t = " << t << " ";
		while (j <= n) {
			if (count == 0) {
				wave = '-';
			}
			else if (count > 0 && count <= k) {
				wave = '^';
				count--;
				spectators++;
			}
			else if (count > k && count <= n) {
				wave = '-';
				wave = '^';
				count--;
				temp++;
			}
			else if (count > n && count <= n + k) {
				wave = '-';
				end++;
				count--;
				spectators = temp;
			}
			else {
				wave = '-';
			}
			// cout << wave;
			j++;
		}
		//cout << " number of standing spectators = " << spectators << endl;
		if (T == t) {
			cout << spectators;
		}
		t++;
	}*/
	return 0;
}

#include <bits/stdc++.h>
#define debug(a); cout<<a<<endl;
using namespace std;

int main() {
long long n=10,k=5,t=7;
 cin>>n>>k>>t;
 long long l=k-(t-n);
 if(t<n+k){
    if(t<=k)cout<<t;
    else if(t>k && t<=n)cout<<k;
    else if(t>k && t>n)cout<<l;

 }
 else cout<<0;

  return 0;
}

#pragma GCC optimize("O2")
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<bitset>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<limits.h>
#include<ctime>
#define N 100001
typedef long long ll;
const int inf=0x3fffffff;
const int maxn=2017;
const int mod=1000000007;
using namespace std;
inline int read()
{
    int f=1,x=0;char ch=getchar();
    while(ch>'9'||ch<'0')
    {
        if(ch=='-')
        f=-1;
        ch=getchar();
    }
    while(ch<='9'&&ch>='0')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return f*x;
}
int main()
{
  ll n=read(),k=read(),i=read();
  if(i<k)cout<<i;
  else if(i>=k&&i<=n)cout<<k;
  else cout<<n+k-i;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
long long n,k,t;
int main()
{
	cin>>n>>k>>t;
	if(t<=k)
	{
		cout<<t;
		return 0;
	}
	else if(t<=n)
	{
		cout<<k;
		return 0;
	}
	else cout<<n+k-t;
	return 0;
}

#include<iostream>
#include<string>
#include<cstdio>
using namespace std;
int main()
{
	int n, k, t;
	cin >> n >> k >> t;
	if (t <= k) { cout << t; return 0; }
	if (t >= n) { cout << k - (t - n); return 0; }
	cout << k;
	return 0;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define max(a,b) a>b?a:b
#define rep(i,x,y) for(register int i = x;i <= y;++i)
#define repd(i,x,y) for(register int i = x;i >= y;--i)
typedef long long ll;
inline void read(ll&x){
	x = 0;char c ;int sign = 1;
	do {c = getchar();if(c == '-') sign = -1; }while(c < '0' ||c > '9');
	do { x = x * 10 + c - '0'; c = getchar(); }while(c <= '9' && c >= '0');
	x *= sign;
}
int main()
{
	ll n,k,t;
	read(n);read(k);read(t);
	if(t <= k) return printf("%I64d",t),0;
	if(t <= n) return printf("%I64d",k),0;
	return printf("%I64d",max(0,n + k - t)),0;
}

#include <iostream>

using namespace std;

int main()
{
    int n, k, t;
    cin>> n;
    cin>> k;
    cin>> t;
    if (t<=k)
        cout<< t;
    else if (t<=n)
        cout<< k;
    else
        cout<< k-t+n;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;

int main()
{
	int n, k ,t;
	cin>>n>>k>>t;
	if(t<=k)
	{
		cout<<t;
	}
	else if(t>k&&t<=n)
	{
		cout<<k;
	}
	else if(t>n)
	{
		cout<<k-(t-n);
	}
	return 0;
}

#include<iostream>
using namespace std;
int main() {
	int n, k, t;
	cin >> n >> k >> t;
	if (t < k)
		cout << t;
	else if (t >= k && t <= n)
		cout << k;
	else
		cout << k - (t - n);
	return 0;
}

#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n,k,i,t;
    cin>>n>>k>>t;
    cout << min(min(t,k),n+k-t);
}

#include <iostream>
#include <algorithm>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char** argv)
{
    int n ,k , t;
    int l,p,b;
    cin>>n>>k>>t;
    b=min(t,k);
    p=min(b,n+k-t);
 	cout<<p;
}

#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll n, k, t;
int main(){
    scanf("%lld %lld %lld", &n, &k, &t);
    if (t <= k)
        printf("%lld", t);
    else if (t < n || t < k)
        printf("%lld", t - (t-k));
    else if (t > n || t > k)
        printf("%lld", k - (t-n));
    return !printf("\n");
}

#include<iostream>
#include<string>
#include<fstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
using namespace std;
ofstream fo("test.out");
ifstream fi("test.inp");
int n, k, t;
int main()
{
	cin >> n >> k >> t;
	if (t <= k) cout << t;
	else
	{
		if (t <= n) cout << k;
		else cout << k - t + n;
	}
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,k,t,a;
    while(cin>>n>>k>>t)
    {
        if(t>=k && t<=n)
        {
            cout<<k<<endl;
            continue;
        }
        else if(t<k)
        {
            cout<<t<<endl;
            continue;
        }
        else if(t>n)
        {
            a=n+(t-n);
            cout<<n-(a-k)<<endl;
        }
    }
    return 0;
}

#include <bits/stdc++.h>
#include <algorithm>
#define ll long long
#define ld long double
#define fir first
#define sec second
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n, k, t;
    cin >> n >> k >> t;
    if(t<=n+k)
        {
            if(t<=k)
                cout << t <<endl;
            else
            if(t>n)
                cout << (n+k-t) <<endl;
            else
                cout << k <<endl;
        }
    else
        cout << 0 <<endl;
    return 0;
}

#include <cstdio>

int main()
{
	int n, k, t;
	scanf("%d %d %d", &n, &k, &t);

	int ret = -1;
	if (t < k)
		ret = t;
	else if (k <= t && t <= n)
		ret = k;
	else
		ret = n + k - t;

	printf("%d", ret);

	return 0;
}

#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

string StrNubmber(ll number)
{
	string ans = "";
	if (number == 1) ans = "1";
	else if (number == 2) ans = "2";
	else if (number == 3) ans = "3";
	else if (number == 4) ans = "4";
	else if (number == 5) ans = "5";
	else if (number == 6) ans = "6";
	else if (number == 7) ans = "7";
	else if (number == 8) ans = "8";
	else if (number == 9) ans = "9";
	else  ans = "0";
	return ans;
}

string ToStr(ll number)
{
	string ans = "";
	while (number / 10 >= 1)
	{
		ans = StrNubmber(number % 10) + "" + ans;
		number /= 10;
	}
	ans = StrNubmber(number % 10) + "" + ans;
	number /= 10;
	return ans;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);

    ll n,k,t;
    cin >> n >> k >>t;
    if(t <= k) cout << t;
    else if(t <=n) cout << k;
    else if(n+k-t >=0) cout << n+k-t;
    else cout << 0;

	//system("pause");
	return 0;
}
/* Otabek Davronbekov | IUT */

#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	long long n,k,t;
	long long ans=0;
	cin>>n>>k>>t;
	if(t<=k) cout<<t<<endl;
    else if(t<=n) cout<<k<<endl;
	else cout<<k-(t-n)<<endl;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,k,t;
    cin >> n >> k >> t;
    if (!t)
        cout << 0;
    else if (t<=k)
        cout << t;
    else if (t>k && t<=n)
        cout << k;
    else
        cout << k-(t-n);
}

#include<bits/stdc++.h>
using namespace std;
int n,k,t;
int main()
{
	cin>>n>>k>>t;
	if(t<=k) cout<<t<<"\n";
	if(k<t&&t<=n) cout<<k<<"\n";
	if(t>n) cout<<n+k-t<<"\n";
	return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include <vector>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <algorithm>
#include <iomanip>
#include <fstream>

using namespace std;

typedef long long LL;

int main() {

#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    LL n, k, t;
    cin >> n >> k >> t;
    if (t >= n + k) {
        cout << 0;
        return 0;
    }
    if (t >= k && t <= n) {
        cout << k;
        return 0;
    }
    if (t < k) {
        cout << t;
        return 0;
    }
    if (t > n) {
        cout << n + k - t;
        return 0;
    }
    return 0;
}

#include <bits/stdc++.h>
//#define ll long long
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("http://in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long
#define pb push_back
#define pll pair<ll,ll>
#define ff first
#define ss second
#define mp make_pair

int main()
{
	  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll n,k,t;
cin>>n>>k>>t;
if(t<=k)
{
	cout<<t;
}
else if(t>n)
{
	//t-=2*k;
	cout<<k-(t-n);
}
else
cout<<k;

}

#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<queue>
#include<deque>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<ctime>
#include<functional>
#define N 1000000005
using namespace std;
typedef long long ll;
//int vis[N];
int main()
{
    int n,k,t;
    scanf("%d%d%d",&n,&k,&t);
    if(t<=k)
        printf("%d\n",t);
    else if(t>k&&t<=n)
    {
        printf("%d\n",k);
    }
    else if(t>n)
    {
        printf("%d\n",n-(t-k));
    }
    return 0;
}

#include<iostream>
#include<set>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
//#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;
#define push_back pb;
template<typename T>void read(T &x)
    {
        register T c = getchar(); x = 0; int t = 0;
        if (c == '-') t = 1, c = getchar();
        for (; (c < 48 || c > 57); c = getchar());
        for (; c > 47 && c < 58; c = getchar()) {
            x = (x << 1) + (x << 3) + c - 48;
        }
        if (t) x = -x;
    }
int main()
{
//ios_base::sync_with_stdio(false); cin.tie(NULL);
ll n,k,t;
cin>>n>>k>>t;
if(t<=k)cout<<t;
else if(t<=n)
{
    cout<<k;
}
else
{
    ll temp=t-k;
    cout<<n-temp;
}
}

#include <bits/stdc++.h>
using namespace std;

int main() {
	long long int n,k,t;
	cin>>n>>k>>t;
	if(t<=k){
	    cout<<t<<endl;

	}
	else if(t>k && t<=n){
	    cout<<k<<endl;
	}
	else if(t>n && t>k){
	    cout<<k-(t-n)<<endl;
	}
}

#include <iostream>

using namespace std;

int main()
{
	int n,k,t;
	cin>>n>>k>>t;
	if(k>=t)
	{
		cout<<t;
		return 0;
	}
	int cnt=0;
	if(t>=k&&t<=n)
	{
		cout<<k;
		return 0;
	}
	if(t>n&&t<=n+k)
	{
		cout<<n+k-t;
		return 0;
	}
	cout<<0;
	return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
int calc,n, k,t,count;
cin >> n >> k >> t;

calc=n-k;
if(t<=k)
{
cout << t;
return 0;}
else if(k<=t && t<=n){
cout <<k;
return 0;}
else if(n<=t&&t<(n+k))
{
cout << n+k-t;

return 0;}}

#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int n,k,t,i,p,c;
    cin>>n>>k>>t;
   if(t<=k)
    cout<<t<<endl;
   else if(t>=k+1&&t<=n)
    cout<<k;
   else if(t>n)
    cout<<k-(t-n)<<endl;
        }

#include<bits/stdc++.h>

#define pb push_back
#define all(v) (v).begin(),(v).end()
#define ll long long int
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define sz(a) (ll)(a.size())
#define MOD 1000000007
#define fi first
#define se second
#define pii pair<ll,ll>

using namespace std;
const ll hell = (ll)(1e18+100LL);

int main(){
	ll t,i,j,k,m,n,x,y;
	t=1;
	//cin>>t;
	while(t--){
		ll flag=0;
		cin>>n>>k>>m;

		if(m<=n){
			cout<<min(k,m);
			return 0;
		}
		cout<<(n+k-m);

	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int n,t,k;
	scanf("%lld %lld %lld", &n, &k, &t);
	if(t<=k){
		printf("%lld\n", t);
	}else if(t<=n){
		printf("%lld\n", k);
	}else if(t>n){
		printf("%lld\n", n-(t-k));
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n,k,t;
  cin>>n>>k>>t;
  if(t<=k)cout<<t;
  else if(k<= t && t <=n)cout<<k;
  else{
    cout<<k-(t-n);
  }
}

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    long long n,k,t;
    scanf("%I64d%I64d%I64d",&n,&k,&t);
    long long ans=0;
    if(t<=k)
        ans=t;
    else if(t>=n)
        ans=n+k-t;
    else
        ans=k;
    printf("%I64d\n",ans);
    return 0;
}

#include <iostream>
using namespace std;

int main(){
long long n, k, t, ans;
cin >> n >> k >> t;
if(n < t){
	ans = k - t;
	ans = n + ans;
	cout << ans;
}else if(t<k){
	cout <<t<<endl;
}else{
	cout << k << endl;
}

return 0;

}

				/*****************************************************
 				*	Logged in : HABIBUR RAHMAN						 *
				*	Dept	  : COMPUTER SCIENCE AND ENGINEERING	 *
				*													 *
				*	KHULNA UNIVERSITY OF ENGINEERING AND TECHNOLOGY  *
				******************************************************/

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<string> vs;
typedef pair<ll,ll> pll;
#define fast_io 			ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) 				v.begin(),v.end()
#define allr(v) 			v.rbegin(),v.rend()
#define rep(i,a,b) 			for(ll i=a;i<=b;i++)
#define rep0(i,n)			for(ll i=0;i<n;i++)
#define rrep0(i, n) 		for(ll i=(ll)(n);i>0;--i)
#define rrep(i, a, b) 		for(ll i=(ll)(a);i>=(ll)(b);--i)
#define pb(z) 				push_back(z)
#define ff					/first
#define ss 					second
#define caset 				int t;cin>>t;for(int tt=1;tt<=t;tt++)
#define sz(X) 				((ll)(X).size())
#define scan(X) 			scanf("%s", (X))
#define ms(v,val)			memset((v),(val),sizeof((v)))
#define ms0(X) 				memset((X), 0, sizeof((X)))
#define ms1(X) 				memset((X), -1, sizeof((X)))
#define m_p(a,b)            make_pair(a,b)
#define get_pos(c,x) 		(lower_bound(c.begin(),c.end(),x)-c.begin())
#define lcm(a,b)            (a*b)/__gcd(a,b)
#define INF9                1000000010
#define INF18               4000000000000000010
#define bpll(a)             __builtin_popcountll(a)
#define sqr(a)              ((a)*(a))
#define nl					"\n"
//#define mod					1e9+7;
#define mx_el(v)			*max_element(all(v));
#define mn_el(v)			*min_element(all(v));
#define pcase(z,x)    		cout<<"Case "<<z<<": "<<x<<"\n"
const double pi = 2*acos(0) ;
#define display(v)			vi :: iterator it;for(it=(v).begin();it!=(v).end();it++){cout << *it << " " ;}cout << endl;
#define taking(n,v) 		for(ll i=0;i<(n);i++){ll inp;cin>>inp;(v).push_back(inp);}

void start(){
      #ifndef ONLINE_JUDGE
      freopen("input.txt" , "r" , stdin) ;
      freopen("output.txt" , "w" , stdout) ;
      #endif
}

void solve()
{
 	 ll n,k,t;cin>>n>>k>>t;
 	 cout << min(n+k-t,min(t,k));
}

int main() {
	fast_io
	//start();
    //caset{
    	//cout << "Case " << tt << ": ";

		  solve();
	//}

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
long long n,k,t,m=0,h,i,j;
int main()
{
	cin>>n>>k>>t;

	if(t<k)
	{
		cout<<t;
	}
	if(t>=k && t<n)
	{
		cout<<k;
	}
	if(t>=n)
	{
		cout<<k-(t-n);
	}
}

#include <bits/stdc++.h>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n, k, t;
	cin >> n >> k >> t;
	int cnt = 0;
	if(t>=k&&t<=n){
		cout << k;
	}else if(t < k){
		cout << t;
	}else{
		cout << k-t+n;
	}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

long long n, k, t;

int main() {
    cin>>n>>k>>t;
    cout<<min(k, min(t, n+k-t))<<endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int n,k,t;
int main()
{
    cin>>n>>k>>t;
    int ans = min(t,n)-max(0,t-k);
    cout<<ans<<endl;
}

#include<iostream>
using namespace std;

int main()
{
	int n,k,t;
	cin >> n >> k >> t;
	int a = min(t,k);
	a=min(a,n+k-t);
	cout<< a<<endl;
	return 0;
}

#include<iostream>
using namespace std;

int main()
{
	int n, k, t;
	cin >> n >> k >> t;
	if (t < k)
		cout << t;
	else if (t > n)
		cout << n + k - t;
	else
		cout << k;

	cout << endl;

	return 0;
}

#include <bits/stdc++.h>

#define fr for (i=1;i<=n;i++)
#define frd for (j=1;j<=n;j++)
#define ex exit (0)

using namespace std;

long long _min, _max, ans, ar, op, inf, mix, mid;
long long a[100500], b[100500], i, j, n;
long long x, r, l, d, e, k, t;
string s,ss;

int main () {
cin >>n>>k>>t;

    if(t <= k)

    cout << t;

    else if(t <= n)

    cout << k;

    else

    cout << n + k - t;

return 0;
}

//Bismillah_Hir_Rahmanir_Rahim

#include<iostream>
#include<stdio.h>
using namespace std;

long long int n,k,t,i,j,sum;

int main()
{
    while(cin>>n>>k>>t)
    {

        sum = n+k;
        if(t<=k)
        {
            cout<<t<<endl;
        }

        else if(t>=k+1 && t<=n)
        {
            cout<<k<<endl;
        }
        else if(t>n && t<=sum)

        {
            cout<<sum-t<<endl;
        }
    }
    return 0;
}

#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#define endl  "\n"
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);
using namespace std;
int main()
{
	int n,k,t;
	cin >> n >> k >> t;
	if(t<=k)
	{
		cout << t;
	}
	else if(t>k && t<=n)
	{
		cout << k;
	}
	else
	{
		cout << max(0,n+k-t);
	}
}

#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
long long n, t, k;
	cin >> n >> k >> t;
	long long ans = k - (t - n);
	if (k>t)
		cout << min(t, n);
	else
	{
		if (t <= n)
			cout << k;
		else

		cout << ans;
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n,k,t;
main(){
cin>>n>>k>>t;
cout<<min(min(t,k),n+k-t);
}

#include<algorithm>
 #include<cstdio>
  #include<cmath>
  #include<cstring>

  const int MAXN = 1000005;

  inline void read(int &x)
  {
     char ch = getchar(),c = ch;x = 0;
     while(ch < '0' || ch > '9') c = ch,ch = getchar();
     while(ch <= '9' && ch >= '0') x = (x<<1)+(x<<3)+ch-'0',ch = getchar();
     if(c == '-') x = -x;
 }

 int main()
 {
     int n,k,t;
     int ans = 0;
     read(n),read(k),read(t);
     if(t <= k)
         ans = t;
     else if((t > k && t <= n))
         ans = k;
     else if(t > n && t < n+k)
         ans = k-(t%n);
     else if(t >= n+k)
         ans = 0;
     printf("%d\n",ans);
     return 0;
 }

#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
using namespace std;
int main(){ FAST
    int n,k,t;
    cin>>n>>k>>t;
    if(t<=n){
        if(t<k)cout<<t<<endl;
        else cout<<k<<endl;
    }
    else{
        t=t-n;
        cout<<k-t<<endl;
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace  std;

#define endl "\n"
#define ll long long
#define li long int
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/gcd(a,b)
#define mx(a,b,c) max(a,max(b,c))
#define mn(a,b,c) min(a,min(a,b))
#define fr(l,r) for(ll i=l;i<r;i++)
#define frr(l,r) for(ll i=r-1;i>=l;i--)
#define rep(n) for(ll i=0;i<n;i++)
#define repr(n) for(int i=n-1;i>=0;i--)
#define repw(n) while(n--)
#define db double
#define ld long double
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int main()
{
 long n , k ,t , ans ;
 cin>>n>>k>>t ;
 if(t<=n)
 	cout<<min(t,k) ;
 else
 	cout<<k-(t-n) ;

}

#include<iostream>
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	int n, k, t;
	cin >> n >> k >> t;
	if (t <= k){
		cout << t << endl; return 0;
	}
	if(t>k && t<n) {
		cout << k << endl; return 0;
	}
	cout << n + k-t << endl;

	return 0;
}

#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL;
LL n,k,t;
int main(){
	cin>>n>>k>>t;
	if(t<=k)cout<<t;
	else if(t>k && t<=n)cout<<k;
	else cout<<k-(t-n);
	return 0;
}

#include <bits/stdc++.h>
#include <climits>
using namespace std;

#define endl                    '\n'
//#define IOS                   ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep()                   for(LL i = 0 ; i < n ; i++)
#define f(i,s,n)                for(LL i = s ; i < n ; i++)
#define fe(i,s,n)               for(LL i = s ; i <= n ; i++)
#define rfe(i,s,n)              for(LL i = s ; i >= n ; i--)
#define TCs(x)                  LL x; cin>>x; while(x--)
#define TC(x)                   LL x=1; while(x--)
#define f2(it,v)                for(it = v.begin(); it != v.end(); ++it)
#define fori(it, x)             for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define auto(m)                 for(auto &it:m)
#define ip(n,a)                 LL n;cin>>n;LL a[n];rep{cin>>a[i];}
#define ip2(n,a,b)              LL n;cin>>n;LL a[n];LL b[n];rep{cin>>a[i];} rep{cin>>b[i];
#define op(n,a)                 f(i,0,n){cout<<a[i]<<" ";}
#define i2p(n,k,a)              LL n,k;cin>>n>>k;LL a[n];rep{cin>>a[i];}
#define mp                      make_pair
#define pb                      push_back
#define ff                      first
#define ss                      second
#define all(v)                  v.begin(), v.end()
#define vsort(v)                sort(all(v))
#define vrsort(v)               reverse(all(v))
#define Max(x,y,z)              max(x,max(y,z))
#define Min(x,y,z)              min(x,min(y,z))
//#define ps(x,y)               fixed<<setprecision(y)<<x
//#define ps(x)                 std::cout << std::fixed; std::cout << std::setprecision(x);
#define clz(a)                  __builtin_clz(a) // count leading zeroes (geeksforgeeks.org/builtin-functions-gcc-compiler/)
#define ctz(a)                  __builtin_ctz(a) // count trailing zeroes
//#define ctz(a)                __builtin_ctzll(a)
#define popc(a)                 __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define GCD(A,B)                __gcd(A,B)
//#define LCM(A,B)              boost::math::lcm(A,B)
//#define COUNT(v,x)             count(all(v),x)
//#define COUNT(v,x)             count(all(s),'x')
#define trace(x)                 cout<<x<<endl
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

//Typedefs:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
typedef string                  S;
typedef long long               LL;
typedef long double             LD;
typedef unsigned long long      ULL;
typedef vector<long long>       VL;
typedef vector<string>          VS;
typedef vector<char>            VC;
typedef pair<LL,LL>             PLL;
typedef pair<string,LL>         PSL;
typedef pair<LL,string>         PLS;
typedef pair<char,LL>           PCL;
typedef pair<LL,char>           PLC;
typedef vector<PLL>             VPLL;
typedef vector<PSL>             VPSL;
typedef vector<PLS>             VPLS;
typedef vector<PCL>             VPCL;
typedef vector<PLC>             VPLC;
typedef map<LL,LL>              MLL;
typedef map<string,LL>          MSL;
typedef map<char,LL>            MCL;
typedef set<LL>                 SL;
typedef set<string>             SS;
typedef set<char>               SC;

//Functions:----------------------------------------------------------------------------------------------------------------------------------------------------------------------
clock_t time_p=clock();
void shahil_005()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//------------------------------------------------------------------------------------//
int power(LL x,LL y)
{
    if (y == 0)
    return 1;
    LL p = power(x, y/2);
    p = (p * p);

    return (y%2 == 0)? p : (x * p);
}
//....................................................................................//
int lcm(LL a,LL b)
{
    LL lar = max(a, b);
    LL small = min(a, b);
    for (LL i = lar; ; i += lar) {
    if (i % small == 0)
        return i;
    }
}
//....................................................................................//
int gcd(LL a,LL b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
//....................................................................................//
int bsearch(LL arr[],LL l,LL r,LL x)
{
    while (l <= r)
    {
    LL m = l + (r - l) / 2;
    if (arr[m] == x){
        return m;
    }
    if (arr[m] < x){
        l = m + 1;
    }
    else
        r = m - 1;
    }
    return -1;
}
//....................................................................................//
bool prime(LL n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;

    // This is checked so that we can skip
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;

    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;

    return true;
}
//....................................................................................//

bool sortbysec(const pair<LL,LL> &a,
                   const pair<int,int> &b)
{
       return (a.second<b.second);
}

//Constants:----------------------------------------------------------------------------------------------------------------------------------------------------------------------
const int N = 1e5 + 5;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Solve:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

void solve()
{
        LL n,k,t;
        cin>>n>>k>>t;
        if(t<=k){
                cout<<t<<endl;
        }
        else if(t<=n){
                cout<<k<<endl;
        }
        else{
                cout<<k-(t-n)<<endl;
        }

}

int main ()
{
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);

#ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
#endif

        TC(t)
        {
                solve();
        }

        shahil_005();
        return 0;
}
/** notes to me from me ---------       // Not mine but helpful
         *
         * aim:
         *      - not to achieve high rating but to improve as a problem solver
         *      - to focus more on solving problems than rating
         *
         * i must remember the following:
         *      - check for overflow
         *      - check for out of bounds read/write
         *      - check for any other errors that will hinder you from AC on first submission
         *      - check logic for special/boundary cases
         *      - think simple, fast and efficient. no need to make things complicated
         *      - spending time to think and test your approach is more valuable than wasting
         *        time on submission and then debugging a wrong solution. you've proven myself
         *        from experience many times. dont be stupid anymore and actually remember this.
         *      - no need to use fancy coding styles and techniques. keep it simple
         *      - don't blank out in the last 30 mins
         *      - no stress at all. stay calm. cool, we got this nigga
         *      - stop checking standings/dashboard. stop comparing
         *      - read all problem statements. sometimes the D's are easier to solve than the B's
         *      - write your ideas down. you've forgotten them a couple of times in the past
         */

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <map>
#include <cstdio>
#include <set>
#include <queue>
#include <iomanip>
#define ll long long
#define pb push_back
int INF=10000000;
using namespace std;
int main()
{
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    //cout<<setprecision(9)<<fixed;
    ll n,k,t;
    cin>>n>>k>>t;
    if(t<k) cout<<t;
    else if(t>n) cout<<k-(t-n)<<endl;
    else cout<<k<<endl;
    return 0;
}

#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
using namespace std;
typedef long long ll;
ll n, k, t;
int main()
{
    while(cin>>n>>k>>t)
    {
        if(t <= k)
        {
            cout<<t<<endl;
            continue;
        }
        if(t <= n)
        {
            cout<<k<<endl;
            continue;
        }
        if(t <= n + k)

        {
            cout<<k - t + n<<endl;
            continue;
        }
        cout<<0<<endl;
    }
    return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#define TEST ""
#define push_back pb
#define make_pair mp
#define first ff
#define second ss
#include <cassert>
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <ctime>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

void solve() {
	ll n, k, t;
	cin >> n >> k >> t;
	if (t <= k) {
		cout << t << endl;
	}
	else if (t < n + 1) {
		cout << k << endl;
	}
	else {
		cout << n + k - t << endl;
	}
}

int main() {
	ios_base::sync_with_stdio(false);
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#elif ONLINE_JUDGE
	//freopen(TEST".in", "r", stdin);
	//freopen(TEST".out", "w", stdout);
#endif
	solve();
	return 0;
}

#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
    long long n, k, t;
    cin >> n >> k >> t;
    if(t<=k) {cout<<t;return 0;}
    if(t>k&&t<=n) {cout<<k;return 0;}
    if(t>n) {cout<<n+k-t;return 0;}
}

#include<bits/stdc++.h>
#include<iomanip>
#include<vector>
#define                           ll                          long long
#define                           int                         ll
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int p[50005];

using namespace std;

main()
{
    fast
     int n,k,t,i,x,d;
     cin>>n>>k>>t;
     if(t<=k)
     {
        cout<<t;
     }
     else if(k<t && t<=n)
     {
        cout<<k;
     }
     else if(t<n+k)
     {
        cout<<k-(t%n);
     }
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define ii pair<int, int>
#define vii vector<ii>
#define vvi vector<vi>
#define vvii vector<vii>
#define ld long double
#define iii tuple<int, int, int>
#define N 1000005

int main() {

    int n, k, t;
    scanf("%d %d %d", &n, &k, &t);

    if(t < k) {
        printf("%d\n", t);
    }
    else if(t <= n) {
        printf("%d\n", k);
    }
    else {
        printf("%d\n", k - (t%n));
    }
}

#include <iostream>
using namespace std;

int main(){

 int n,k,t;
 cin>>n>>k>>t;

 if(k>=t){cout<<t;return 0;}

 if(n>=t){cout<<k;return 0;}

 k=n+k-t;

 k>=0? cout<<k:cout<<0;

 return 0;
}

#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
int main()
{
   int k,n,t;
   while(cin>>n>>k>>t)
   {
   	if(t<k)
	   cout<<t<<endl;
	  else if(t>n)
	   cout<<k+n-t<<endl;
	  else cout<<k<<endl;
	}
	return 0;
}

#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
void init()
{
	int k,n,t,ans=0;
	cin>>n>>k>>t;
	if(t<=k)
		cout<<t<<endl;
	else if(t>k&&t<=n)
		cout<<k<<endl;
	else  cout<<(k-t+n)<<endl;
}
int main()
{
	init();
	return 0;
}

#include <iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<string>
using namespace std;

int main() {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);

	//printf("%d %d %d", a, b, c);
	//printf("\n %d %d\n", c - a, c - b);
	if (c < a && c < b)
		printf("%d", c);
	else if ((c -a) <= 0 || (c - b) <= 0) {
		//printf("in");
		if (a > b)
			printf("%d", b);
		else
			printf("%d", a);
	}
	else
		printf("%d", a + b - c);
}

#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;

int main()
{
    ll n,k,t,x ;
    cin >> n >> k >> t ;

   x = min(t,min(k,n+k-t));
   cout << x << endl ;
    return 0;
}

#include <iostream>
using namespace std;
int main()
{
	long long n,k,t;
	cin>>n>>k>>t;
	if(t>k&&t<n)
		cout<<k;
	else if(t<=k)
		cout<<t;
	else if(n<=t&&t<=n+k)
		cout<<k+n-t;

}

#include <bits/stdc++.h>
using namespace std;

int main()
{
   int n, k, t;
   cin >> n >> k >> t;
   if (t <= k)
   {
       cout << t << endl;
   }
   else if (t > k && t <= n)
   {
       cout << k << endl;
   }
   else if (t > n && t > n+k)
   {
       cout << (n+k) - t << endl;
   }
}

#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll m,n,k,t,i,j,ans;
int main()
{
	cin>>n>>k>>t;

	if (k>=t && n>=t)
	{
		cout<<t<<endl;
		return 0;
	}

    i=n-t; j=k-t;

    if (i<0 && j<0)
    {
    	ans+=k;

    	ans+=n-t;

    	cout<<ans<<endl;
	}

    if (i<0 && j>0)
    {
    	ans+=n-t;

    	if (ans<0)
    	cout<<0<<endl;
    	else
    	cout<<ans<<endl;
    	return 0;
	}

	if (i>0 && j<0)
	{
		ans+=k;

		cout<<ans<<endl;
		return 0;
	}

	return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int x;
    cin >> x;
    for(int a=1; a<=x; a++){
        for(int b=1; b<=x; b++){
            if(a%b==0 && a/b < x && a*b>x){
                cout << a << " " << b;
                return 0;
            }
        }
    }
    cout << -1;
}

#include <iostream>
#include <string>
#include <math.h>
#include <set>
#include<sstream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
//#include <bits/stdc++.h>
using namespace std;

int main(){
	int n, k, t;
	cin >> n >> k >> t;
	int stand = 0;

	if (t <= k)
		stand = t;
	else if (t < n && t > k)
		stand = k;
	else if (t > n)
		stand = k-(t-n);

	cout << stand;
}

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>

using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

int main(){
	ll n,k,t;
	unsigned int ans=0;
	cin>>n>>k>>t;
/*	//rep(i,n+k){
	for(ll i=1;i<=n+k;i++){
		if(i<=k){
			ans++;
		}
		else if(i>n){
			ans--;
		}
		if(i==t){
			cout<<ans<<endl;
			return 0;
		}
	}
	*/
	if(t<=k)
		cout<<t<<endl;
	else if(t>k&&t<=n)
		cout<<k<<endl;
	else if(t>n&&n+k>t){
		cout<<(t-n+1)<<endl;
	}
	else
		cout<<(n+k-t)<<endl;
	return 0;
}

#include <bits/stdc++.h>

#define ll long long
using namespace std;

int main() {

    int n, k, t; cin >> n >> k >> t;

    if (t>k && t<n){
        cout << k << endl;
    }else{
        if (t<k){
            cout << t << endl;
        }
        if (t>n){
            cout << (n+k)-t << endl;
        }
    }

    return 0;
}

#include<bits/stdc++.h>

using namespace std;

int main() {
	long long n, k, t;
	cin >> n >> k >> t;
	if (t <= k) {
		cout << t;
	}
	else if (t > n) {
		cout << t + k - n ;
	}
	else {
		cout << k;
	}

	return 0;
}

#include<iostream>
using namespace std;
int main()
{
	int n,k,t;
//	cout<<"Enter the number of spectators: "<<endl;
	cin>>n;
//	cout<<"Enter the standing people: "<<endl;
	cin>>k;
//	cout<<"Enter the time: "<<endl;
	cin>>t;
	if(t<k && n>k){
		cout<< t <<endl;
	}
	if(k<t && t<n && n>k){
		cout<< k <<endl;
	}
	if (t>k && t>n && n>=k && t< n+k){
		cout<<k+n-t<<endl;
	}
	if(t>k && t>n && n>k && t >= n + k ){
		cout<<0<<endl;
	}
    if(n==k==t){
    	cout<<n<<endl;
	}
	return 0;
}

#include <bits/stdc++.h>
#define ll             long long
#define f(i,a,b)       for(int i=(a);i<(b);i++)
#define fd(i,a,b)      for(ll i=(a);i>(b);i--)
#define x              first
#define y              second
#define si(a)          scanf("%d",&a)
#define sii(a,b)       scanf("%d %d",&a,&b)
#define siii(a,b,c)    scanf("%d %d %d",&a,&b,&c)
#define sl(a)          scanf("%I64d",&a)
#define sll(a,b)       scanf("%I64d %I64d",&a,&b)
#define slll(a,b,c)    scanf("%I64d %I64d %I64d",&a,&b,&c);
#define pfci(n,ans)    printf("Case %I64d: %d\n",n,ans)
#define pfcl(n,ans)    printf("Case %I64d: %I64d\n",n,ans)
#define pfcd(n,ans)    printf("Case %I64d: %lf\n",n,ans)
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define MOD 1000000009
#define ld long double
#define mp make_pair
using namespace std;
#define INF 1e12
#define EPS 1e-7

int main()
{
    ll n,k,t;
    cin>>n>>k>>t;
    if(t<=n) cout<<t<<endl;
    else if(t<=n+k) cout<<(n+k)-t<<endl;
    else cout<<"0"<<endl;
}

#include <bits/stdc++.h>
using namespace std;

map<string,int> mp;

int main()
{
    int n;
    string s;
    cin >>n;
    for (int i=0; i<n; i++)
    {
        cin >> s;
        if (!mp[s])
            cout << "OK" << endl;
        else
            cout << s << mp[s] << endl;
        mp[s]++;
    }
    return 0;
}

#include<iostream>
using namespace std;
int main()
{
	int n,k,t;
//	cout<<"Enter the number of spectators: "<<endl;
	cin>>n;

//	cout<<"Enter the standing people: "<<endl;
	cin>>k;

//	cout<<"Enter the time: "<<endl;
	cin>>t;

	if(t<k && n>=k){
		cout<< t <<endl;
	}
	if(k<t && t<=n && n>=k){
		cout<< k <<endl;
	}
	if (t>k && t>n && n>=k && t< n+k){

		cout<<k+n-t<<endl;
	}
	if( t > n + k)
	cout<<k<< 0 <<endl;
	return 0;

}

#include<iostream>
using namespace std;
int main()
{
	int n,k,t;
//	cout<<"Enter the number of spectators: "<<endl;
	cin>>n;
//	cout<<"Enter the standing people: "<<endl;
	cin>>k;
//	cout<<"Enter the time: "<<endl;
	cin>>t;
	if(t<k && n>k){
		cout<< t <<endl;
	}
	if(k<t && t<n && n>k){
		cout<< k <<endl;
	}
	if (t>k && t>n && n>k && t< n+k){
		cout<<k+n-t<<endl;
	}
	if(t>k && t>n && n>k && t > n + k ){
		cout<<0<<endl;
	}
	if(t=k=n){
		cout<<n;
	}

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,k,t,res=0;
    cin>>n>>k>>t;
    for(int i=1;i<=t;i++)
    {
        if(i<=k) res++;
        else if(i>=n) res--;
    }
    cout<<res;
}

#include <iostream>

using namespace std;

int main()
{
    int n,k,t,l=0;
    cin>>n>>k>>t;
    if(t<=k) l=t;
    else
        if(t>k && t<=n) l=k;
    else
        if(t>n) l=n+n-k-t;
    cout<<l;
    return 0;
}

#include <iostream>

using namespace std;

int main()
{
  int k,n,t;

  cin >> k>> n>>t;

  if (k+n > t || k==n)cout << (k+n)-t;
  if (t<n || (k==n && k== t))cout << t;
  else cout << n;
  return 0;

}

#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ll long long
#define fi first
#define se second
#define pb push_back
#define mod 1000000007

int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	fast;

	int n,k,t;
	cin>>n>>k>>t;
	if(t<5)
		cout<<t;
	else if(t>=5&&t<=10){
		cout<<k;
	}
	else
		cout<<n+k-t;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{

    int n=15,k=5,t=1;

    cin>>n>>k>>t;
    if(t<=k)
        cout<<t;
    else if(t<n&&t<=2*k)
        cout<<k;
    else cout<<abs(n-t+k);

}

#include<iostream>
using namespace std;
int main()
{
	int n,k,t;
//	cout<<"Enter the number of spectators: "<<endl;
	cin>>n;
//	cout<<"Enter the standing people: "<<endl;
	cin>>k;
//	cout<<"Enter the time: "<<endl;
	cin>>t;
	if(t<k && n>k){
		cout<< t <<endl;
	}
	if(k<t && t<n && n>k){
		cout<< k <<endl;
	}
	if (t>k && t>n && n>k && t< n+k){
		cout<<k+n-t<<endl;
	}
	if(t>k && t>n && n>k && t > n + k ){
		cout<<0<<endl;
    }
     if(n==k && n==t){
     	cout<<t;
	 }
	 if(n==k && n>t){
	 	cout<<t;
	 }

	return 0;
}

#include <iostream>
using namespace std;

int main ()
{
    int n, k, t;
    cin >> n >> k >> t;
    t = t % (n + k);
    if (n - k > t) cout << t;
    else if (n - k <= t and t <= n) cout << n - k;
    else if (t > n) cout << k - (t - n);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n,k,t;
  cin>>n>>k>>t;
  if(t<=k)cout<<t;
  else if(t<=2*k)cout<<k;
  else{
    cout<<k-(t-n);
  }
}

#define ll long long
#define ull unsigned long long
#define elif else if
#define FOR(i,n) for (int i=0; i<n; ++i)
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <string>
#include <iomanip>
#include <deque>
using namespace std;
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
	ull n,k,t;
	cin >> n >> k>>t;
	if (t>=n)
	{
		++t;
		t-=n;
	}
	if (t<k)
		cout<<min(t,n);
	else
		cout<<k;
	return 0;
}

#include<bits/stdc++.h>
using namespace  std;

#define endl "\n"
#define ll long long
#define li long int
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b/gcd(a,b)
#define mx(a,b,c) max(a,max(b,c))
#define mn(a,b,c) min(a,min(a,b))
#define fr(l,r) for(ll i=l;i<r;i++)
#define frr(l,r) for(ll i=r-1;i>=l;i--)
#define rep(n) for(ll i=0;i<n;i++)
#define repr(n) for(int i=n-1;i>=0;i--)
#define repw(n) while(n--)
#define db double
#define ld long double
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int main()
{
 long n , k ,t ;
 cin>>n>>k>>t ;
 cout<<min(t,k) ;

}

#include <bits/stdc++.h>

using namespace std;

int main(int argc, char const *argv[])
{
	long long n,k,t;
	cin>>n>>k>>t;
	if(t < k)
	{
		cout<<t<<endl;
	}
	else if((t>=k) && (t<n))
	{
		cout<<k<<endl;
	}
	else if(t>=n)
	{
		cout<<k-t-n+1<<endl;
	}
	return 0;
}

#include<stdio.h>
int main ()
{
	long long int n,k,t,i,j,p;
	scanf("%lld %lld %lld",&n,&k,&t);
	if(t<=k)
	p=t;
	else if(k<=t&&t<=n)
	p=k;
	else
	p=t-n;
	printf("%lld\n",p);
	return 0;
}

#include<bits/stdc++.h>
#include<iomanip>
#include<vector>
#define                           ll                          long long
#define                           int                         ll
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int p[50005];

using namespace std;

main()
{
    fast
     int n,k,t,i,x,d;
     cin>>n>>k>>t;
     if(t<=k)
     {
        cout<<t;
     }
     else if(k<t && t<=n)
     {
        cout<<k;
     }
     else if(t<n+k)
     {
        cout<<k-(t%k);
     }
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int a,b,c,limit=-1;
    cin >> a >> b >> c;
    for(int i=0;i<=a+b;i++){
        if(limit!=b && i<a){limit++;}
        if(i>=a+1){limit--;}
        if(i==c){cout << limit;return 0;}
    }
}

#include"bits/stdc++.h"
using namespace std ;

int main()
{
	long long N,K,T;

	cin>>N>>K>>T;

	if(T>=K && T<=K+K)
	cout<<K<<"\n";
	else
	{
		if(T>K+K)
		cout<<N+K-T<<"\n";
		else
		cout<<T<<"\n";
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;

int main()
{
	int n,k,t;
	cin >> n >> k >> t;
	int count=0;

		if(t == 0)
		{
			cout << "0";
		}
		if(t >= k && t <= n)
		{
			cout << k;
		}
		if(t > n)
		{
			cout << n+k-t;
		}

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	int n,m,k;
	cin>>n>>m>>k;
	if(k<=n and k>m){
		cout<<m<<'\n';
	}else if(k<=n and k<m){
		cout<<k<<'\n';
	}else if(k>n){
		cout<<m-(k-n)<<'\n';
	}
}

#include <iostream>
#include <string>
using namespace std ;

int main()
{

    int n,k,t;

cin>>n>>k>>t;
if (t<=k) cout<<t<<endl;
else
{
if (t<n)
 cout<<k<<endl;
else if (t>n)
 cout<<k-(t%n)<<endl;
}
 return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n,k,t;
  cin>>n>>k>>t;
  if(t<=k)cout<<t;
  else if(t<=2*k)cout<<t;
  else{
    cout<<k-(t-n);
  }
}

# include<iostream>
using namespace std;
long long n, k, t;
int main()
{
	cin >> n >> k >> t;
	int a = n / k;
	int b = a * k;
	if (t <= k)
		cout << t << endl;
	else if (t > k && t <= b)
	{
		cout << k;
	}

	else {
		int ans = k - t + n;
		if (ans >= 0) cout << ans << endl;
		else cout << 0 << endl;
	}
}

#include <bits/stdc++.h>
//#define ll long long
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("http://in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long
#define pb push_back
#define pll pair<ll,ll>
#define ff first
#define ss second
#define mp make_pair

int main()
{
	  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll n,k,t;
cin>>n>>k>>t;
if(t<=k)
{
	cout<<t;
}
else if(t>2*k)
{
	t-=2*k;
	cout<<n-t;
}
else
cout<<k;

}

#include<iostream>
using namespace std;
int main()
{
	int n,k,t,count=0;
	int temp=0;
	cin>>n;
	cin>>k;
	bool Array[n+k];
	cin>>t;
	for(int i=0; i<n; i++)
	{
	     Array[i]=0;
	}
	for(int i=0; i<n+k; i++)
	{
		if(i>k)
		{
			Array[i]=1;
			Array[temp]=0;
			temp++;
		}
		else
		{
			Array[i]=1;
			count++;
		}
		if(i==t-1)
		{
		    cout<<count;
		    break;
		}
	}
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,t;
  cin>>n>>k>>t;
  if(k>t) cout<<t<<endl;
  else if(n==t || k<=t)
    cout<<k<<endl;
  else cout<<k-(t-n)<<endl;
  return 0;
}

#include <iostream>
#include <cstdio>
using namespace std;

int main()
{
    int n, k, t, ans;
    scanf("%d%d%d", &n, &k, &t);
    if(t <= k ){
        ans = k;
    }else if (t > n){
        ans = k - (t - n);
    }
    else{
        ans = k;
    }
    printf("%d\n", ans);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long  int n,k,t;
    cin>>n>>k>>t;
    if(t<=k)
    {
        cout<<t<<endl;
        return 0;
    }
    if(t>k&&t<=n-k)
    {
        cout<<k<<endl;
        return 0;
    }
     if(t>n-k)
    {
        cout<<n+k-t<<endl;
        return 0;
    }

    return 0;
}

#include <iostream>

using namespace std;

int main()
{

    int k,n,t;

    cin >> k,n,t;

    if (t>k)cout << k+n-t;
    if (t<n)cout <<t;
    else cout<<n;
    return 0;
}

#include<iostream>
using namespace std;

int main()
{
	int n,k,t,a[100000],d=0;
	cin>>n>>k>>t;
	int i;
	for(i=0;i<=n+k;i++)
	{
		a[i]=d;
		if(i>=0 && i<k)d++;
		if(i>=n && i<n+k) d--;
	}
	t=t%(n+k);
	t=t-1;
	cout<<a[t];
}

#include <iostream>
using namespace std;
int main()
{
	int n,m,t;
	while(cin>>n>>m>>t)
	{
		t=t%(n+m);
		if(t<m) cout<<t<<endl;
		else if(t>2*m) cout<<(m-(t-2*m))<<endl;
		else cout<<m<<endl;
	}
	return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>

int main(void) {
	long long n, k, t;
	scanf("%d %d %d", &n, &k, &t);
	if (t <= k) {
		printf("%d", t);
	}
	else if (t <= n) {
		printf("%d", k);
	}
	else {
		printf("%d\n", k - t + n);
	}
}

#include<stdio.h>
int main()
{
    long long int n,k,t;
    scanf("%lld%lld%lld",&n,&k,&t);
    if(t==0) printf("0");
    else if(t==k) printf("%lld",t);
    else if(t==n) printf("%lld",n-k);
    else if(t>k&&t<n) printf("%lld",k);
    else if (t<k) printf("%lld",t);
    else if(t>n) printf("%lld",k+n-t);
}

#include <bits/stdc++.h>
using namespace std;

int main(){
        long long n, k, t;
        cin >> n >> k >> t;
        long long count;
        if (t <= k) {count = t;}
        else count = n+k-t;
        cout << count;
        return 0;
}

#include <iostream>
 using namespace std;

 int main()
 {
    long n,k,t;

    cin >> n >> k >> t;

    if(k < t  &&  t < n )
    {
       cout << k << endl;
    }
    else if(t > k)
    {
       cout << ((k+n)-t) << endl;
    }
    else if(t < k)
    {
       cout << t << endl;
    }
 }

#include<bits/stdc++.h>
#define ll long long int
#define llu unsigned long long int
#define db double
#define bsa(v,n,a) binary_search(v,v+n,a)
#define bsv(v,a) binary_search(v.begin(),v.end(),a)
#define PI 3.1415926535897932
using namespace std;
const db eps=1e-6;
const db inf=1e9;
const ll INF=1e-15;
const ll mod=1e9+7;
const ll MAX=1e5+5;
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   ll n,k,t;
   cin>>n>>k>>t;
   if(t<k){
    cout<<t;
   }
   else if(t>k && t<n){
    cout<<k;
   }
   else if(t>k && t>n){
    if(n-k-(t%n)<0) cout<<0;
    else cout<<n-k-(t%n);
   }
 return 0;
}

#include<bits/stdc++.h>
using namespace std;

int main(){
	long long  n ,k ,t;
	cin>>n>>k>>t;
	while (t>n+k) t-= (n+k);
	if(t<=k) cout<<t;
	else if(t>k&&t<n) cout<<k;
	else
        {
            switch(t)
            {
                case 10: cout<<5; break;
                case 11: cout<<4; break;
                case 12: cout<<3; break;
                case 13: cout<<2; break;
                case 14: cout<<1; break;
                case 15: cout<<0; break;

            }
        }
}

#include <bits/stdc++.h>

#define fr  for (i=1;i<=n;i++)
#define frd for (j=1;j<=n;j++)
#define ex exit(0)

using namespace std;

long long a[100500],b[100500],i,j,n;
long long was,kz,ans=0,cnt,ar,mid,max,min;
long long c,d,e,k,f,t,x,m=1,o;
string s,ss;
bool ok;

int main () {
	cin >>n>>k>>t;
     if (t==1 || t==14){
     cout <<1;
}
     if (t==2 || t==13){
     cout <<2;
}
     if (t==3 || t==12){
     cout <<3;
}
     if (t==4 || t==11){
	 cout <<4;
}
	 if (t==5 || t==6 || t==7 || t==8 || t==9 || t==10){
	 cout <<5;
}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,t;
    cin>>n>>k>>t;
    if(t<=k)
        cout<<k;
    else if(t>k&&t<=2*k)
        cout<<k;
    else
        cout<<abs(n-t)+1;

}

#include<iostream>

using namespace std;

int main(){

int n,k,t;

cin>>n>>k>>t;

if(t==1){
    cout<<1<<endl;
    return 0;
}

if(t==2){
    cout<<2<<endl;
     return 0;
}
if(t==k){
    cout<<k<<endl;
     return 0;
}
if(t<k){
    cout<<t<<endl;
     return 0;
}

if(k<t){
    cout<<k<<endl;
     return 0;
}

if(t==k+1){
    cout<<k<<endl;
     return 0;
}
if(t==k+2){
    cout<<k<<endl;
     return 0;
}

if(t==n){
        int p=n-k;
int q=n-p;
    cout<<q<<endl;
     return 0;
}
if(t<n+k)
{
cout<<n+k-t<<endl;
 return 0;
}

if(t==n+k){
    cout<<0<<endl;
     return 0;
}

return 0;

}

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <math.h>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#pragma warning(disable:4996)

#define Zero(a) memset(a, 0, sizeof(a))
#define Neg(a)  memset(a, -1, sizeof(a))
#define All(a) a.begin(), a.end()
#define PB push_back
#define repf(i,a,b) for(i = a;i <= b; i++)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define root 1,n,1
#define ld rt << 1
#define rd rt << 1 | 1
#define ll long long
#define MAXN 10010
#define INF 6666666
#define mod 1000000007
#define ll long long
using namespace std;
int n, k, t;
int main()
{
	while (cin >> n >> k >> t) {
		if (t < n) cout << t << endl;
		if (t >= n && t <= n + k) cout << t - k << endl;
	}
	return 0;
}

#include <stdio.h>

using namespace std;

int n, k, t, i;

int main(){

	scanf("%d%d%d", &n, &k, &t);

	int c = 0;
	if(k<t && t<n)
		c = t - (t-k);
	else if(t > n)
		c = n+k-t;
	else
		c = t;

	printf("%d", c);
}

#include"bits/stdc++.h"
using namespace std ;

int main()
{
	long long N,K,T;

	cin>>N>>K>>T;

	if(T>=K && T<=N)
	cout<<K<<"\n";
	else
	{
		if(T>K+N)
		cout<<N+K-T<<"\n";
		else
		cout<<T<<"\n";
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,k,t;
    scanf("%I64%I64d%I64d",&n,&k,&t);
    if(t<k) printf("%I64d\n",t);
    else if(t>n) printf("%I64d\n",k-t+n);
    else printf("%I64d\n",k);
    return 0;
}

#include <bits/stdc++.h>

#define INF 0x3f3f3f3f
#define NINF -0x3f3f3f3f

using namespace std;

typedef pair<int,int> pii;

int main (int argc, char const* argv[])
{
	int n,k,t;
	scanf("%d %d",&n,&k);
	scanf("%d",&t);

	if (n == 1)
	{
		printf("0\n");
		return 0;
	}

	if (t <= k)
		printf("%d\n",t);
	else if (t <= n)
		printf("%d\n",n-k);
	else
		printf("%d\n",n+k-t);

	return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <map>
#include <cstdio>
#include <set>
#include <queue>
#include <iomanip>
#define ll long long
#define pb push_back
int INF=10000000;
using namespace std;
int main()
{
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    //cout<<setprecision(9)<<fixed;
    ll n,k,t;
    cin>>n>>k>>t;
    if(t>k)
    {
        cout<<k<<endl;
    }
    ll p=1;
    ll f=0;
    for(int i=0;i<t;i++){
        if(p<=n)
        {
            f++;
        }
        int pos=0;
        if(p<=n&&p>k)
        {
            f--;
            pos=p-k;
        }
        if(p>=n&&pos!=p-k)
        {
            f--;
        }
        p++;
    }
    cout<<f<<endl;
    return 0;
}

#include <iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<string>
using namespace std;

int main() {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if (c < a && c < b)
		printf("%d", c);
	else if ((a - c)*(b - c) <= 0)
		printf("%d", a < b ? a : b);
	else
		printf("%d", a + b - c);
}

#include<iostream>
using namespace std;
int main()
{
	int n,k,t;
//	cout<<"Enter the number of spectators: "<<endl;
	cin>>n;
//	cout<<"Enter the standing people: "<<endl;
	cin>>k;
//	cout<<"Enter the time: "<<endl;
	cin>>t;
	if(t<k && n>k){
		cout<< t <<endl;
	}
	if(k<t && t<n && n>k){
		cout<< k <<endl;
	}
	if (t>k && t>n && n>=k && t< n+k){
		cout<<k+n-t<<endl;
	}
	if(t>k && t>n && n>k && t >= n + k ){
		cout<<0<<endl;
	}

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n,k,t,m=0,h,i,j;
int main()
{
	cin>>n>>k>>t;
	h=n-k+1;
	if(t<h)
	{
		cout<<t;
	}
	if(t>=h && t<k+h)
	{
		cout<<k;
	}
	if(t>=k+h)
	{
		cout<<k-(t-n);
	}
}

#include<bits/stdc++.h>
using namespace std;
int n,k,t;
int main()
{
	cin>>n>>k>>t;
	if(t<=k) cout<<t<<"\n";
	if(t>=k&&t<=n) cout<<k<<"\n";
	if(t>n) cout<<n+k-t<<"\n";
	return 0;
}

#include<iostream>
using namespace std;

int n,m,k,z;

main(){
    cin>>n>>m>>k;
    if(n==m&&m==k){cout<<n;return 0;}
    if(k>m)z=k-n;
    if(k<=m)cout<<m-(m-k);
    if(z<0)cout<<m;
    if(z>0)cout<<m-z;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long int n,k,t;

    cin>>n>>k>>t;
    t=(t%(3*k));
    if(t<=k)
    {
        cout<<t;
        return 0;
    }
    if(t>k && t<=(2*k))
    {
        cout<<k;
        return 0;
    }
    if(t>2*k && t<=(3*k))
    {
        cout<<k-(t%(2*k));
        return 0;
    }

}

#include <iostream>

using namespace std;

int main()
{
    int n,k,t,l=0;
    cin>>n>>k>>t;
    if(t<=k) l=t;
    else
        if(t>k && t<=n) l=k;
    else
        if(t>n) l=n+n-k-t;
    cout<<l;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long ax,ay,bx,by,cx,cy;
    cin>>ax>>ay>>bx>>by>>cx>>cy;
    if((((bx-ax)*(bx-ax))+((by-ay)*(by-ay)))==(((cx-bx)*(cx-bx))+((cy-by)*(cy-by)))&&((bx-ax)*((cy-by))!=((by-ay)*(cx-bx)))){

        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1e9;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, k, t;
    cin >> n >> k >> t;
    if(t <= k){
        cout << t << endl;
    }
    else if(t > k && t <= n){
        cout << n-k << endl;
    }
    else if(t > n){
        cout << n+k-t << endl;
    }

    return 0;
}

#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
    int n, k, t;
    cin >> n >> k >> t;
    if(k <= t){
        cout << t << endl;
    }
    else if (t <= n)
        cout << k << endl;
    else if(t <= n + k){
        cout << n + k - t << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
int main()
{
   int k,n,t;
   while(cin>>n>>k>>t)
   {
   	if(t<k)
	   cout<<t<<endl;
	  else if(t>n-k)
	   cout<<n-k<<endl;
	  else cout<<k<<endl;
	}
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, k, t;

    scanf("%d%d%d", &n, &k, &t);
    if(n > k && k > t)
        printf("%d\n", t);
    else if(n == k)
        printf("%d\n", t);
    else if(n > t && k <= t)
        printf("%d\n", k);
    else if(n == t)
        printf("%d\n", t);
    else if(n < t)
        printf("%d\n", ((n + k) - t));
    return 0;
}

#include <bits/stdc++.h>

using namespace std;
int main(){
	int n,k,t,x,y;
	cin >> n >> k >> t;
	x=floor(t/k);
	y=floor(t/n);
	if(t<=k)	cout << t;
	if(t>=k && t<=n)	cout << k;
	if(t>=n && t<=n+k)	cout << n+k-t;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k,t;
	cin>>n>>k>>t;
	if(t<=k)cout<<t;
	else if(k<=t<=n)cout<<k;
	else if(n<=t<=n+k)cout<<n+k-t;
	return 0;
}

#include <iostream>

using namespace std;

int main()
{
    int n,k,t,p;
    cin>>n>>k>>t;
    if(t<k)
        cout<<t<<endl;
    else if(k<t && t<n)
        cout<<k<<endl;
    else if(t>=n)
    {p=(t-n)%k;
        cout<<k-p<<endl;}
}

#include <iostream>

using namespace std;

int main()
{
	int n;
	int k;
	int t;
	cin >> n >> k >> t;
	int standing = 0;

	if ( k >= t || n >=t)
	{
		cout << k << endl;
	    return 0;
	}
	if (n < t && k < t)
	{
		standing = n + k - t;
		cout << standing << endl;
	    return 0;
	 }
}

#include <iostream>

using namespace std;
int broj(int n,int k,int t)
{
  if(k>t)
    return t;
  else
  {
      if(t<n)
        return k;
      else
      {
          if(t%n<=k)
            return t%n;
          else
            return k;
      }
  }

}
int main()
{
    int n,k,t;
    cin>>n>>k>>t;
    cout<<broj(n,k,t);

    return 0;
}

#include<iostream>
using namespace std;
int main()
{
	int n,k,t;
//	cout<<"Enter the number of spectators: "<<endl;
	cin>>n;
//	cout<<"Enter the standing people: "<<endl;
	cin>>k;
//	cout<<"Enter the time: "<<endl;
	cin>>t;
	if(t<=k && n>k){
		cout<< t <<endl;
	}
	if(k<=t && t<=n && n>k){
		cout<< k <<endl;
	}
	if (t>k && t>n && n>k && t< n+k){
		cout<<k+n-t<<endl;
	}
	if( t >= n + k){
		cout<<k<<0<<endl;
	}
    if(n==k && k==t){
    	cout<<k<<endl;
	}
	return 0;
}

/*Be on your guard; stand firm in the faith; be courageous; be strong.
																									- Corinthians 16:13 */
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(a,b) for(int i=a; i<=b; i++);
int main(){
	ll n,k,t;
	scanf("%lld%lld%lld",&n,&k,&t);
	ll count = k;
	for(int i=k+1; i<=t; i++){
		if(i>n){
			count--;
		}
	}
	printf("%lld\n",count);
}

#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
int main ()
{
    long long n,k,t;
    scanf ("%I64d",&n);
    scanf ("%I64d",&k);
    scanf ("%I64d",&t);
    long long counter=0;
    long long m=1;
    while (m!=t+1)
    {
        if (m>n)
        {
            counter--;
        }
        else if (counter>=k);
        else counter++;
        m++;

    }
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int x;
    cin >> x;
    for(int a=1; a<=x; a++){
        for(int b=1; b<=x; b++){
            if(a%b==0 && a/b <= x && a*b>=x){
                cout << a << " " << b;
                return 0;
            }
        }
    }
    cout << -1;
}

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <iomanip>
#include<algorithm>
#include<stdio.h>
using namespace std;

int main()
{
    int n,k,t;
    cin>>n>>k>>t;
	if(t>n){
		t=t%n+1;
	}
    cout<<min(k,t);
}

#include <bits/stdc++.h>

using namespace std;

int n, k ,t;
int main()
{
    cin >> n >> k >> t;
    int ans = 1000000;
    if(t > n){
        ans = k-(t-n);
    }
    ans = min(ans,min(t,k));
    cout << ans << endl;
    return 0;
}

#include <iostream>
using namespace std;

int main(){
long long n, k, t, ans;
cin >> n >> k >> t;
if(n < t){
	ans = k - t;
	ans = n + ans;
	cout << ans;
}if(t<k){
	cout <<t;
}else{
	cout << k;
}

return 0;

}

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define clr(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
typedef pair<ll, ll> pii;
typedef vector< ll > vl;
typedef vector< pii > vpii;
const ll N= 1e6+55,mod = 1e9+7;
int main() {
// 	freopen("Task.in","r",stdin);freopen("Task.out","w",stdout);
	ll ans,n,k,t;
	sc(n);sc(k);sc(t);
	if(t<=k)ans=t;
	else if(t>k && t<=n)ans=k;
	else ans=2*n-k-t;
	if(ans<0)ans=0;
	pr(ans);
}

#include<bits/stdc++.h>
using namespace std;
long long n,k,t;
main(){
cin>>n>>k>>t;
cout<<(t>2*k?k-abs(n-t):min(k,t));
}

#include<iostream>
using namespace std;
int main()
{
    long long n,k,t;
    cin>>n>>k>>t;
    if(t<=k)
    cout<<t<<endl;
    else if(t>=n)
    cout<<t-n<<endl;
    else
    cout<<k<<endl;
}

#include<iostream>
using namespace std;
int main(){
	long long i,j,n,k,t;
	long long a[100000];
	cin>>n>>k>>t;
	if(t<k){
		cout<<t;
	}
	if(t>=k&&t<n){
		cout<<k;
	}
	if(t>=n){

		cout<<(t-k)-(n-k)+1;
	}
	return 0;
}

#include <cstdio>

int main() {
  int n, t, k;
  scanf("%d%d%d", &n, &k, &t);
  if (t < k) {
    printf("%d\n", t);
  } else if (t < n) {
    printf("%d\n", k);
  } else {
    printf("%d\n", t - n + 1);
  }
  return 0;
}

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stack>
#include <deque>
#include <cstdio>
#include <string>
#include <cstring>
using namespace std;

int main()
{
	int n, k, t, res;
	cin >> n >> k >> t;

	if(t < n && t < k) {
		res = t*floor(k/t);
	}else if(t < n && t >= k) {
		res = k;
	}else {
		res = floor(t/k);
		int op = floor(t/n);
		if(op % 2 != 0)
			res++;
	}

	cout << res << endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    long n,k,t;
    cin>>n>>k>>t;
    if(t<=k){
        cout<<t;
    }
    else if(t<=n){
        cout<<n-k;
    }
    else{
        cout<<(n-k)-(t-n);
    }

    return 0;
}

#include <iostream>
#include <string>
using namespace std ;

int main()
{

    int n,k,t;

cin>>n>>k>>t;
if (t<=k) cout<<t<<endl;
else
{
if (t<n)
 cout<<k<<endl;
else if (t>n)
 cout<<k-(t%n)<<endl;
}
 return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a , b , c;
    cin >> a >> b >> c;
    if(c>b)
    {
        cout << a+b-c << endl;
        return 0;
    }
    else{
        cout << c << endl;
    }
    }

#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<queue>
#include<deque>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<ctime>
#include<functional>
#define N 1000000005
using namespace std;
typedef long long ll;
//int vis[N];
int main()
{
    ll n,k,t;
    scanf("%lld%lld%lld",&n,&k,&t);
    if(t<=k)
        printf("%I64d\n",t);
    else if(t>k&&t<n)
    {
        ll d=t-(k+t+n)%k;
        printf("%I64d\n",d);
    }
    else if(t==n)
    {
        printf("%I64d\n",k);
    }
    else if(t>n)
    {
        printf("%I64d\n",n-(t-k));
    }
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, k, t;
    cin >> n >> k >> t;
    if (t < k) cout << t;
    else if (t > n) cout << max(t - n + 1, 0);
    else cout << k;
    return 0;
}

#include <iostream>
using namespace std;
long long n, k, t, ans;
int main()
{
	cin >> n >> t >> k;
	if(t <= k) cout << t;
	else if(t <= n) cout << k;
	else cout << n + t - k;
	return 0;//返回值为0
}

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, k, t;
	cin >> n >> k >> t;
	ll res = 0;
	if(t <= k){
		res = t;
	}
	else if(t > n){
		cout << k - (t-n);
	}
	else if(t>k && t<=n){
		res = k;
	}
	cout << res << endl;
	return 0;
}

#include<bits/stdc++.h>
#define forn(i, n) for(int i = 1; i <= n; i++)
#define forab(a, b) for(int i = a; i <= b; i++)

using namespace std;

const int INF = 1e7;
const long double EPS = 1e-8;
const long double PI = acos(-1.0L);
const int MAXN = 50;
const int MAXC = 1e9;

long long n, spl, i, m, k1, t,  ans, sum, k, mid, p;

int main() {
    //freopen("merge.in", "r", stdin);
    //freopen("merge.out", "w", stdout);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> k >> t;
    if (t < n - k) {
        k1 = t;
    }
    if (n - k <= t && t <= n) {
        k1 = k;
    }
    if (n < t && t <= n + k)
        k1 = n + k - t;
    cout << k1;
    return 0;
}

#include<bits/stdc++.h>

#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007

using namespace std;

int main()
{
	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif

	long n,k,t,ans;

	cin >> n >> k >> t;

	if(t<=k)
		ans=t;
	if(k<=t<=n)
		ans=k;
	if(n<=t<n+k)
		ans=n+k-t;

	cout << ans << endl;

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long int ans=0,n,k,t;

    cin>>n>>k>>t;
    t=(t%(3*k));
    if(t<=k)
    {
        cout<<t;
    }
    else if(t>k && t<=(2*k))
    {
        ans=0;
        if(t>n)
        {
            ans=t-n;
        }
        cout<<k-ans;
    }
    else if(t>2*k && t<=(3*k))
    {
        cout<<k-(t%(2*k));
    }

}

#include<iostream>
using namespace std;
int main()
{
    int n,k,t;
    cin>>n>>k>>t;
    if(t<=n)
        cout<<t;
    else if(t>n && t<=n)
        cout<<k;
        else
        cout<<(n+k)-t;
}