Arpa is researching the Mexican wave.There are n spectators in the stadium, labeled from 1 to n. They start the Mexican wave at time 0.   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. Arpa wants to know how many spectators are standing at time t.

The first line contains three integers n, k, t (1 ≤ n ≤ 109, 1 ≤ k ≤ n, 1 ≤ t < n + k).

Print single integer: how many spectators are standing at time t.

NoteIn the following a sitting spectator is represented as -, a standing spectator is represented as ^.  At t = 0  ----------  number of standing spectators = 0.  At t = 1  ^---------  number of standing spectators = 1.  At t = 2  ^^--------  number of standing spectators = 2.  At t = 3  ^^^-------  number of standing spectators = 3.  At t = 4  ^^^^------  number of standing spectators = 4.  At t = 5  ^^^^^-----  number of standing spectators = 5.  At t = 6  -^^^^^----  number of standing spectators = 5.  At t = 7  --^^^^^---  number of standing spectators = 5.  At t = 8  ---^^^^^--  number of standing spectators = 5.  At t = 9  ----^^^^^-  number of standing spectators = 5.  At t = 10 -----^^^^^  number of standing spectators = 5.  At t = 11 ------^^^^  number of standing spectators = 4.  At t = 12 -------^^^  number of standing spectators = 3.  At t = 13 --------^^  number of standing spectators = 2.  At t = 14 ---------^  number of standing spectators = 1.  At t = 15 ----------  number of standing spectators = 0.

import java.util.*;

public class Main {
    private static Scanner scanner = new Scanner(System.in);
    public static void main(String[] args) {
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int t = scanner.nextInt();
        if(t < k) {
            System.out.println(t);
        } else if(t <= n) {
            System.out.println(k);
        } else {
            System.out.println(k - t + n);
        }
    }
}

// 432

import java.util.*;
import java.io.*;

public class MexicanWave{

	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int numCase = 1;
		String l = "";
		while((l = br.readLine()) != null){
			String[] line = l.split(" ");
			int n = Integer.parseInt(line[0]);
			int k = Integer.parseInt(line[1]);
			int t = Integer.parseInt(line[2]);

			if(t < k)
				System.out.println(t);
			else if(t > n){
				if(t > k + n)
					System.out.println("0");
				else
					System.out.println((k + n - t));
			}
			else
				System.out.println(k);

			numCase++;
		}

		br.close();
	}

}

//package mexican.wave;

import java.util.Scanner;

public class MexicanWave {

    public static void main(String[] args) {
        Scanner in =new Scanner(System.in);
        int n=in.nextInt();
        int k=in.nextInt();
        int t=in.nextInt();
        int ans=0;
        if(t==0)
            ans=0;
        else if(t%(n+k) == 0)
            ans=0;
        else if(t<=k)
            ans=(t);
        else if(t<=n)
            ans=k;
        else if(t>n)
            ans=k-(t%n);
        System.out.print(ans);
    }
}

	import java.util.*;

	public class Code {

		public static void main(String[] args) {
			Scanner in = new Scanner(System.in);
			int n = in.nextInt();
			int k = in.nextInt();
			int t = in.nextInt();
			if ( t <= k) {
				System.out.println(t);
			} else if (t <= n) {
				System.out.println(k);
			} else {
				System.out.println(k-(t-n));
			}
	}
}

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class ArpaAndMexicanWave {

	public static void main(String[] args) {

		try{

			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			String in = reader.readLine();

			String inp[] = in.split(" ");
			int n = Integer.parseInt(inp[0]);
			int k = Integer.parseInt(inp[1]);
			int t = Integer.parseInt(inp[2]);

			if( t<=k)
			{
				System.out.println(t);
			}

			else if(t>=k && t<=n)
			{
				System.out.println(k);
			}

			else if(t>=n && t<=(n+k))
			{
				System.out.println(n+k-t);
			}

		}
		catch(Exception e)
		{
			e.printStackTrace();
		}

	}

}

//M O H A M M A D || A M E E N || S A E D || A B O H A S A N
import java.util.*;
public class mohammad {
    public static void main(String[] args) {
        HashMap<Character,Integer> map = new HashMap<>();
        Scanner sc =new Scanner(System.in);
        long n = sc.nextLong();
        long k = sc.nextLong();
        long t = sc.nextLong();
        if(t <= k) System.out.println(t);
        else if(t <= n) System.out.println(k);
        else System.out.println(n+k-t);
    }
}

import java.util.Scanner;
import java.io.PrintWriter;

public class ArpaAndResearchInMexicanWave{
    public static void main(String args[]){
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = in.nextInt();
		int k = in.nextInt();
		int t = in.nextInt();

		if(t <= k)out.print(t);
        else if(k<t && t<=n)out.print(k);
        else out.print(Math.min(k,n+k-t));

        out.close();
    }
}

import java.util.*;

public class Test1 {
	public static void main(String[] args) {
	    Scanner in = new Scanner(System.in);
	    String input = in.nextLine();
		String[] strs = input.trim().split(" ");
		int[] ins = new int[strs.length];

		for (int i = 0; i < strs.length; i++) {
			ins[i] = Integer.parseInt(strs[i]);
		}

		if((ins[0] <= 1000000000) && ((ins[1] <= ins[0]) && (ins[1] >= 1)) && ((ins[2] <= ins[0] + ins[1]) && (ins[2] >= 1))) {
			if(ins[2] <= ins[1]) {
				System.out.print(ins[2]);
			}
			else if((ins[1] <= ins[2]) && (ins[2] <= ins[0])) {
				System.out.print(ins[1]);
			}
			else {
				System.out.print((ins[0] + ins[1]) - ins[2]);
			}
		}
	}
}

import java.util.Scanner;

public class Leetcode {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt(), k = scan.nextInt(), t = scan.nextInt();
		scan.close();
		if (t <= k) {
			System.out.println(t);
		} else if (t > k && t <= n) {
			System.out.println(k);
		} else {
			System.out.println(k - (t - n));
		}
	}
}

import java.util.Scanner;
public class Maratona1 {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        long n = s.nextLong();
        long k = s.nextLong();
        long t = s.nextLong();
        if(t<n&&t<k){
            System.out.println(t);
        }else if(t<n && t>=k){
            System.out.println(k);
        }else{
            System.out.println((n+k)-t);
        }
    }
    }
// 1507984414832

import java.io.*;
import java.util.*;
import java.text.*;
import java.lang.*;
import java.math.BigInteger;
import java.util.regex.*;
public class Myclass {
	public static boolean visited[]=new boolean[300001];
	static ArrayList [] a=new ArrayList[300001];
	public static Vector<Integer>v=new Vector<>();
	public static void dfs(int n)
	{
		visited[n]=true;
		v.add(n);
		for(int i=0;i<a[n].size();i++)
		{
			int temp=(int) a[n].get(i);
			if(!visited[temp])
				dfs(temp);
		}
	}
	public static void main(String[] args)
	{
	    InputReader in = new InputReader(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		long n=in.nextLong();
		long k=in.nextLong();
		long t=in.nextLong();
		if(t<=k)
			pw.println(t);
		else if(t>k&& t<n)
			pw.println(k);
		else
			pw.println(k-(t-n));

		pw.flush();
		pw.close();

	}

		static class InputReader
		{
		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream)
		{
			this.stream = stream;
		}
		public int snext()
		{
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars)
			{
				curChar = 0;
				try
				{
					snumChars = stream.read(buf);
				}
				catch (IOException e)
				{
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt()
	    {
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			int sgn = 1;
			if (c == '-')
		    {
				sgn = -1;
				c = snext();
			}
			int res = 0;
			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong()
	    {
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = snext();
			}
			long res = 0;
			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n)
		{
			int a[] = new int[n];
			for (int i = 0; i < n; i++)
			{
				a[i] = nextInt();
			}
			return a;
		}

		public String readString()
	    {
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = snext();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine()
		{
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = snext();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c)
		{
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c)
		{
			return c == '\n' || c == '\r' || c == -1;
		}

		public interface SpaceCharFilter
	    {
			public boolean isSpaceChar(int ch);
		}
	}
		public static long mod = 1000000007;
		public static int d;
		public static int p;
		public static int q;

		public static int[] suffle(int[] a,Random gen)
		{
			int n = a.length;
			for(int i=0;i<n;i++)
			{
				int ind = gen.nextInt(n-i)+i;
				int temp = a[ind];
				a[ind] = a[i];
				a[i] = temp;
			}
			return a;
		}

		public static void swap(int a, int b){
			int temp = a;
			a = b;
			b = temp;
		}

		public static HashSet<Integer> primeFactorization(int n)
		{
			HashSet<Integer> a =new HashSet<Integer>();
			for(int i=2;i*i<=n;i++)
			{
				while(n%i==0)
				{
					a.add(i);
					n/=i;
				}
			}
			if(n!=1)
				a.add(n);
			return a;
		}

		public static void sieve(boolean[] isPrime,int n)
		{
			for(int i=1;i<n;i++)
				isPrime[i] = true;

			isPrime[0] = false;
			isPrime[1] = false;

			for(int i=2;i*i<n;i++)
			{
				if(isPrime[i] == true)
				{
					for(int j=(2*i);j<n;j+=i)
						isPrime[j] = false;
				}
			}
		}

		public static int GCD(int a,int b)
		{
			if(b==0)
				return a;
			else
				return GCD(b,a%b);
		}

		public static long GCD(long a,long b)
		{
			if(b==0)
				return a;
			else
				return GCD(b,a%b);
		}

		public static void extendedEuclid(int A,int B)
		{
			if(B==0)
			{
				d = A;
				p = 1 ;
				q = 0;
			}
			else
			{
				extendedEuclid(B, A%B);
				int temp = p;
				p = q;
				q = temp - (A/B)*q;
			}
		}

		public static long LCM(long a,long b)
		{
			return (a*b)/GCD(a,b);
		}

		public static int LCM(int a,int b)
		{
			return (a*b)/GCD(a,b);
		}

		public static int binaryExponentiation(int x,int n)
		{
		    int result=1;
		    while(n>0)
		    {
		        if(n % 2 ==1)
		            result=result * x;
		        x=x*x;
		        n=n/2;
		    }
		    return result;
		}

		public static long binaryExponentiation(long x,long n)
		{
		    long result=1;
		    while(n>0)
		    {
		        if(n % 2 ==1)
		            result=result * x;
		        x=x*x;
		        n=n/2;
		    }
		    return result;
		}

		public static int modularExponentiation(int x,int n,int M)
		{
		    int result=1;
		    while(n>0)
		    {
		        if(n % 2 ==1)
		            result=(result * x)%M;
		        x=(x*x)%M;
		        n=n/2;
		    }
		    return result;
		}

		public static long modularExponentiation(long x,long n,long M)
		{
		    long result=1;
		    while(n>0)
		    {
		        if(n % 2 ==1)
		            result=(result * x)%M;
		        x=(x*x)%M;
		        n=n/2;
		    }
		    return result;
		}

		public static long modInverse(int A,int M)
		{
		    return modularExponentiation(A,M-2,M);
		}

		public static long modInverse(long A,long M)
		{
		    return modularExponentiation(A,M-2,M);
		}

		public static boolean isPrime(int n)
		{

		    if (n <= 1)  return false;
		    if (n <= 3)  return true;

		    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;
		}

		 public static long[] shuffle(long[] a, Random gen){
		        for(int i = 0, n = a.length;i < n;i++){
		            int ind = gen.nextInt(n-i)+i;
		            long d = a[i];
		            a[i] = a[ind];
		            a[ind] = d;
		        }
		        return a;
		    }
		static class pair implements Comparable<pair>
		{
			Long x;
			Integer y;
			pair(long a,int m)
			{
				this.x=a;
				this.y=m;
			}

		public int compareTo(pair o) {
				int result = x.compareTo(o.x);
				if(result==0)
					result = y.compareTo(o.y);

				return result;
			}

			public String toString()
			{
				return x+" "+y;
			}

			public boolean equals(Object o)
			{
				if (o instanceof pair)
			    {
					pair p = (pair)o;
					return p.x == x && p.y == y ;
				}
				return false;
			}

			public int hashCode()
			{
				return new Long(x).hashCode()*31 + new Long(y).hashCode();
			}
		}
}

import java.util.*;
public class CodeForces {

	public void MexicanWave(){

		Scanner input = new Scanner(System.in);
		int nspectator = input.nextInt();
		int kspectator = input.nextInt();
		int time = input.nextInt();

		if(time <= kspectator)
			System.out.println(time);
		else if(time > kspectator && time <= nspectator)
			System.out.println(kspectator);
		else
			System.out.println(kspectator - (time - nspectator));
	}
		public static void main(String[] args) {
		new CodeForces().MexicanWave();

	}

}

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;
import java.util.ArrayList;
import java.util.PriorityQueue;

public class Solution
{

    /*--------------solution--------------*/ //PROBABLY WRONG LOL
    public static void main(String[] args)
    {
        Reader in = new Reader(System.in);
        PrintWriter out = new PrintWriter(System.out);

       int n = in.nextInt() ,
               k = in.nextInt() ,
               t = in.nextInt() , ans = 0;

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

        out.println(ans);
        out.close();
    }
    /*--------------solution--------------*/

    ///////////////////////////////////////////////////////////////////////////////////

    /*------------fast io------------*/
    static class Reader
    {

        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public Reader(InputStream in)
        {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next()
        {
            while(tokenizer == null || !tokenizer.hasMoreTokens())
            {
                try
                {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch(IOException e) {
                    e.printStackTrace();
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt()
        {
            return Integer.parseInt(next());
        }

    }
  /*------------fast io------------*/

}

import java.util.Scanner;

public class Arpa {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int k=s.nextInt();
		int t=s.nextInt();
		if(t<=k){
			System.out.println(t);
		}
		else if(t<=n)
			System.out.println(k);
		else if(t<=(n+k)){
			System.out.println(k-t+n);
		}
		else{
			System.out.println("0");
		}
	}

}

import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
			solve();
	}
	public static void solve() {
		int n = sc.nextInt();
		int k = sc.nextInt();
            int t = sc.nextInt();

            if(t<=n)
		System.out.println(Math.min(t, k));
		else
		System.out.println(k-t+n);
	}
}

import java.util.Scanner;

/**
 *
 * @author mustafa
 */
public class A {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int k = sc.nextInt();
        int t = sc.nextInt();

        if (t < k)
            System.out.println(t);
        else{
            if(t >= k && t <= n)
                System.out.println(k);
            else
                System.out.println(n + k - t);
        }
    }
}

import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

/* spar5h */

public class codeforces implements Runnable {

	public void run() {

		InputReader s = new InputReader(System.in);
		PrintWriter w = new PrintWriter(System.out);

		long n = s.nextLong();
		long k = s.nextLong();
		long t = s.nextLong();

		long ans = -1;

		if(t < k) {

			ans = t;
		}

		else if(t >= k && t <= n) {

			ans = k;
		}

		else if(t > n) {

			ans = k - (t - n);
		}

		w.println(ans);

		w.close();
	}

	static class InputReader
	{
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream)
		{
			this.stream = stream;
		}

		public int read()
		{
			if (numChars==-1)
				throw new InputMismatchException();

			if (curChar >= numChars)
			{
				curChar = 0;
				try
				{
					numChars = stream.read(buf);
				}
				catch (IOException e)
				{
					throw new InputMismatchException();
				}

				if(numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public String nextLine()
		{
			BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
			String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
		}
		public int nextInt()
		{
			int c = read();

			while(isSpaceChar(c))
				c = read();

			int sgn = 1;

			if (c == '-')
			{
				sgn = -1;
				c = read();
			}

			int res = 0;
			do
			{
				if(c<'0'||c>'9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			while (!isSpaceChar(c));

			return res * sgn;
		}

		public long nextLong()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = read();
			}
			long res = 0;

			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			while (!isSpaceChar(c));
				return res * sgn;
		}

		public double nextDouble()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = read();
			}
			double res = 0;
			while (!isSpaceChar(c) && c != '.')
			{
				if (c == 'e' || c == 'E')
					return res * Math.pow(10, nextInt());
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			if (c == '.')
			{
				c = read();
				double m = 1;
				while (!isSpaceChar(c))
				{
					if (c == 'e' || c == 'E')
						return res * Math.pow(10, nextInt());
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					m /= 10;
					res += (c - '0') * m;
					c = read();
				}
			}
			return res * sgn;
		}

		public String readString()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = read();
			}
			while (!isSpaceChar(c));

			return res.toString();
		}

		public boolean isSpaceChar(int c)
		{
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public String next()
		{
			return readString();
		}

		public interface SpaceCharFilter
		{
			public boolean isSpaceChar(int ch);
		}
	}

	public static void main(String args[]) throws Exception
	{
		new Thread(null, new codeforces(),"codeforces",1<<26).start();
	}

}

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution
{
 public static void main(String[] args) throws Exception
 {
     BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
     String l=in.readLine();
     String[] str=l.trim().split("\\s+");
     long n=Long.parseLong(str[0]);
     long k=Long.parseLong(str[1]);
     long t=Long.parseLong(str[2]);
     if(t>=1 && t<=k)
     {
         System.out.println(t);
     }
     else if(t>=k+1 && t<=n)
     {
         System.out.println(k);
     }
     else if(t>=n+1 && t<=n+k)
     {
         System.out.println(k-t+n);
     }
 }
}

import java.io.BufferedInputStream;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(new BufferedInputStream(System.in));
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int t = scanner.nextInt();
        if(t <= k) System.out.println(t);
        else if(t > k && t<=n) System.out.println(k);
        else System.out.println(k - (t-n));
    }
}

import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class WetShark
{
    static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }
 static int max(int a[],int n) {
	 int max=a[0];
	 int ind=0;
	 for(int i=1;i<n;i++) {
		 if(a[i]>=max) {
			 max=a[i];
			 ind=i;
		 }
	 }
	 return ind;
 }
 static int min(int a[],int n) {
	 int min=a[0];
	 int ind=0;
	 for(int i=1;i<n;i++) {
		 if(a[i]<min) {
			 min=a[i];
			 ind=i;
		 }
	 }
	 return ind;
 }
 static boolean fun(int i) {
	 for(int j=3;j<=20;j++) {
		 if(i%j!=0) {
			 return false;
		 }
	 }
	 return true;
 }
 static int bin(int arr[], int l, int r, int x)
 {
     if (r>=l)
     {
         int mid = l + (r - l)/2;

         if (arr[mid] == x)
            return mid;

         if (arr[mid] > x)
            return bin(arr, l, mid-1, x);
         return bin(arr, mid+1, r, x);
     }

     return -1;
 }
    public static void main(String[] args) throws IOException
    {
        Reader s=new Reader();
        int n=s.nextInt();
       int k=s.nextInt();
       int t=s.nextInt();
       int a=Math.min(k,n+k-t);
       System.out.println(Math.min(a, t));

}
}

/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Wave
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc=new Scanner(System.in);
		int n,k,t;
		n=sc.nextInt();
		k=sc.nextInt();
		t=sc.nextInt();
		int ans=0;
		if(t<=k)
			ans=t;
		else if(t<=n && t>k)
			ans=k;
		else if(t>n)
			ans=k-(t-n);
		System.out.println(ans);
	}
}

//package mexican.wave;

import java.util.Scanner;

public class MexicanWave {

    public static void main(String[] args) {
        Scanner in =new Scanner(System.in);
        int n=in.nextInt();
        int k=in.nextInt();
        int t=in.nextInt();
        int ans=0;
        if(t==0)
            ans=0;
        else if(t%(n+k) == 0)
            ans=0;
        else if(t<=k)
            ans=(t);
        else if(t<=n)
            ans=k;
        else if(t>n)
            ans=k-(t%n);
        System.out.print(ans);
    }
}

import static java.lang.Double.parseDouble;
import static java.lang.Double.valueOf;
import static java.lang.Long.max;
import static java.lang.Long.min;
import static java.lang.Integer.max;
import static java.lang.Integer.min;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.StrictMath.abs;
import static java.lang.System.err;
import static java.lang.System.exit;
import static java.util.Arrays.sort;

import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;

public class A {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    static void solve() throws Exception {
        int n = nextInt(), k = nextInt(), t = nextInt();
        if(t<=n) {
            if(t<=k) out.print(t);
            else out.print(k);
        } else {
            out.print(k-(t-n));
        }
    }

    public static int[] convertIntegers(List<Integer> integers) {
        int[] ret = new int[integers.size()];
        for (int i = 0; i < ret.length; i++) {
            ret[i] = integers.get(i).intValue();
        }
        return ret;
    }

    public static int lower_bound(int[] nums, int target) {
        int low = 0, high = nums.length - 1;
        while (low < high) {
            int mid = low + (high - low) / 2;
            if (nums[mid] < target)
                low = mid + 1;
            else
                high = mid;
        }
        return nums[low] == target ? low : -1;
    }

    public static int upper_bound(int[] nums, int target) {
        int low = 0, high = nums.length - 1;
        while (low < high) {
            int mid = low + (high + 1 - low) / 2;
            if (nums[mid] > target)
                high = mid - 1;
            else
                low = mid;
        }
        return nums[low] == target ? low : -1;
    }

    static int gcd(int a, int b) {
        return b == 0 ? a : gcd(b, a % b);
    }

    static char nextChar() throws IOException {
        return next().toCharArray()[0];
    }

    static int nextInt() throws IOException {
        return parseInt(next());
    }

    static long nextLong() throws IOException {
        return parseLong(next());
    }

    static double nextDouble() throws IOException {
        return parseDouble(next());
    }

    static String next() throws IOException {
        while (tok == null || !tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    public static void main(String[] args) {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(new OutputStreamWriter(System.out));
            solve();
            long lEndTime = System.currentTimeMillis();
            //System.out.println("Elapsed time in seconds: " + (double)(lEndTime - lStartTime) / 1000.0);
            in.close();
            out.close();
        } catch (Throwable e) {
            e.printStackTrace();
            exit(1);
        }
    }
}

import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		if(c==0) {
			System.out.print(0);
		}else {
			if(c<=b)
				System.out.print(c);
			else if(c>a)
				System.out.print(b-(c-a));
			else
				System.out.print(b);
		}
	}
}

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws Throwable
	{
		Scanner sc = new Scanner((System.in));
		int n = sc.nextInt();
		int k = sc.nextInt();
		int t = sc.nextInt();
		if(t<=k)
		{
			System.out.println(t);
			return;
		}
		if(t>k && t<=n)
		{
			System.out.println(k);
			return;
		}
		System.out.println(k-(t-n));
	}

	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}
		public Scanner(String s) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(s));
		}
		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {return Integer.parseInt(next());}

		public String nextLine() throws IOException {return br.readLine();}

		public long nextLong() throws IOException {return Long.parseLong(next());}

		public boolean ready() throws IOException {return br.ready();}
	}
}

import java.util.Scanner;

public class Main {
    public static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        long n = scanner.nextLong();
        long k = scanner.nextLong();
        long t = scanner.nextLong();

        if (t>=k && t<=n){
            System.out.println(k);
        } else if (t < k){
            System.out.println(t);
        } else if (t > n){
            System.out.println(k-t+n);
        }

    }
}

//M O H A M M A D || A M E E N || S A E D || A B O H A S A N
import java.util.*;
public class mohammad {
    public static void main(String[] args) {
        HashMap<Character,Integer> map = new HashMap<>();
        Scanner sc =new Scanner(System.in);
        long n = sc.nextLong();
        long k = sc.nextLong();
        long t = sc.nextLong();
        if(t <= k) System.out.println(t);
        else if(t <= n) System.out.println(k);
        else System.out.println(n+k-t);
    }
}

//import java.util.ArrayList;
import java.util.Scanner;

public class JavaApplication1 {

    public static void main(String[] args) {

       Scanner in=new Scanner(System.in);
    int n=in.nextInt();
    int k=in.nextInt();
    int t=in.nextInt();
    if(t<k)
    {
        System.out.println(t);
    }
    else if(n<t)
    {
        System.out.println(k-(t-n));

    }
    else
    {
        System.out.println(k);
    }

    }
}

import java.util.*;

public class Solution {

  private static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    int n = sc.nextInt(), k = sc.nextInt(), t = sc.nextInt();
    if (t <= k) {
      System.out.println(t);
    } else if (t >= n) {
      System.out.println(k + n - t);
    } else {
      System.out.println(k);
    }
  }

}

//========================================================================
// This conversion was produced by the Free Edition of
// C++ to Java Converter courtesy of Tangible Software Solutions.
// Order the Premium Edition at https://www.tangiblesoftwaresolutions.com
//========================================================================
import java.util.Scanner;
public class GlobalMembers
{
	public static void main (String[]args)
	{
            Scanner kbd = new Scanner(System.in);
		int n = kbd.nextInt();
		int k = kbd.nextInt();
		int t = kbd.nextInt();

		if  (t <= k && k!=0 && t <= n)
		{
			System.out.print(t);
			System.out.print("\n");
		}
		else if (t <= n)
		{
			System.out.print(k);
			System.out.print("\n");
		}
		else
		{
			System.out.print(Math.max(0, k - (t - n)));
			System.out.print("\n");
		}
	}

}

/*
######  ######    #####  ######  ######  #####
 #   #  #    #      #    #    #  #    #    #
 #   #  # #  #      #    # ## #  # ## #    #
 #   #  #  #    #   #    #    #  #    #    #
######  #   #   # # #    #    #  #    #    #
 */
import java.util.*;
public class codeforcesproblem{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long n = scan.nextLong();
		long k = scan.nextLong();
        long t = scan.nextLong();
        long m=0;
        if(t<=k){
            System.out.println(t);
        }else if(t>k && t<=n){
            System.out.println(k);
        }else{
            System.out.println(k-(t-n));
        }

	}
}

import java.util.*;

public class Arpa {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n, k, t;
        String input = scan.nextLine();
        String inputLine[] = input.split(" ");
        n = Integer.parseInt(inputLine[0]);
        k = Integer.parseInt(inputLine[1]);
        t = Integer.parseInt(inputLine[2]);

        if(t <= k && t <= n) {
            System.out.print(t);
        } else if(t <= n) {
            System.out.print(k);
        } else {
            if(0 < k - (t - n)) {
                System.out.print(k - (t - n));
            } else {
                System.out.print(0);
            }
        }
    }
}

import java.util.*;
import java.io.*;
public class Main {

	static ArrayList<Integer> adj[];
	static char color[];
	static boolean b[],visited[],possible;
	static Map<Integer,HashSet<Integer>> s;
	static int totalnodes,colored;
	static int count[];
	static long sum[];
	static double ans=0;
	static long[] as=new long[10001];
	public static void main(String[] args) throws IOException {

		in=new InputReader(System.in);
		w=new PrintWriter(System.out);
   long n=in.nextLong(),k=in.nextLong(),t=in.nextLong();
	      if(t>k && t<=n)
	    	  w.print(k);
	      else if(t<=k)
	    	  w.print(t);
	      else if(t>n)
	    	  w.print(n+k-t);

       w.close();
		}

	public static void dfs(int v,boolean visited[], ArrayList<Integer>[] g )
	    {

	        visited[v] = true;
	        Iterator<Integer> i = g[v].listIterator();
	        while (i.hasNext())
	        {
	            int n = i.next();
	            if (!visited[n])
	            {
	            	ans++;
	            	dfs(n, visited,g);
	            }
	        }
	    }

	public static String[] subString(String s, int n)
	{
	    String[] st =new String[(n*n+n)/2];
	    for(int i=0;i<st.length;i++)
	    	st[i]="";
	    int l=0;
	    for (int len = 1; len <= n; len++)
	    {
	        // Pick ending point
	        for (int i = 0; i <= n - len; i++)
	        {
	            //  Print characters from current
	            // starting point to current ending
	            // point.
	            int j = i + len - 1;
	            for (int k = i; k <= j; k++)
	                st[l]+=s.charAt(k);
	      //w.println(st[l]);
	            l++;
	            //cout << endl;
	        }
	    }
	    return st;
	}
	  public static long factorial(long n)
	    {
	        long res = 1, i;
	        for (i=2; i<=n; i++)
	            res *= i;
	        return res;
	    }

	public static int factors(int n,int start){
		int count = 0;
		int i;
		for(i=1;i*i<n;i++)
			if(n%i == 0){
				if(i>start)	count++;
				if(n/i > start)	count++;
			}
		if(i*i == n && i>start)	count++;
		return count;
	}

 	public static int isPrime(int n){
	    int i;

	    if (n==2)
	        return 1;

	    if (n%2==0)
	        return 0;

	    for (i=3;i<=Math.sqrt(n);i+=2)
	        if (n%i==0)
	            return 0;

	    return 1;
	}

	static InputReader in;
	static PrintWriter w;
	public static void seive(long n){
		b = new boolean[(int) (n+1)];
	Arrays.fill(b, true);
		for(int i = 2;i*i<=n;i++){
			if(b[i]){
				sum[i]=count[i];
			//	System.out.println(sum[i]+" wf");
				for(int p = 2*i;p<=n;p+=i){
					b[p] = false;
					sum[i]+=count[p];
					//System.out.println(sum[i]);
				}
			}

		}
	}
	static class Pair implements Comparable<Pair> {
		char c;
		int count;
		public Pair(){

		}
		public Pair(char u, int v) {
			this.c = u;
			this.count= v;

		}
		public int compareTo(Pair other) {

				return 0;
		}

		/*public String toString() {
			return "[u=" + u + ", v=" + v + "]";
		}*/
	}
	static class Node2{
		Node2 left = null;
		Node2 right = null;
		Node2 parent = null;
		int data;
	}

	//binaryStree
	static class BinarySearchTree{
		Node2 root = null;
		int height = 0;
		int max = 0;
		int cnt = 1;
		ArrayList<Integer> parent = new ArrayList<Integer>();
		HashMap<Integer, Integer> hm = new HashMap<Integer, Integer>();
		public void insert(int x){
			Node2 n = new Node2();
			n.data = x;
			if(root==null){
				root = n;
			}
			else{
				Node2 temp = root,temp2 = null;
				while(temp!=null){
					temp2 = temp;
					if(x>temp.data) temp = temp.right;
					else temp = temp.left;
				}
				if(x>temp2.data) temp2.right = n;
				else temp2.left = n;
				n.parent = temp2;
				parent.add(temp2.data);
			}
		}
		public Node2 getSomething(int x, int y, Node2 n){
			if(n.data==x || n.data==y) return n;
			else if(n.data>x && n.data<y) return n;
			else if(n.data<x && n.data<y) return getSomething(x,y,n.right);
			else return getSomething(x,y,n.left);
		}
		public Node2 search(int x,Node2 n){
			if(x==n.data){
				max = Math.max(max, n.data);
				return n;
			}
			if(x>n.data){
				max = Math.max(max, n.data);
				return search(x,n.right);
			}
			else{
				max = Math.max(max, n.data);
				return search(x,n.left);
			}
		}
		public int getHeight(Node2 n){
			if(n==null) return 0;
			height = 1+ Math.max(getHeight(n.left), getHeight(n.right));
			return height;
		}
	}
public static void debug(Object... o) {
	System.out.println(Arrays.deepToString(o));
}

public static String rev(String s)
{
	StringBuilder sb=new StringBuilder(s);
	sb.reverse();
	return sb.toString();
}

static long lcm(long a, long b)
{
    return a * (b / gcd(a, b));
}

static long gcd(long a, long b)
{
    while (b > 0)
    {
        long temp = b;
        b = a % b; // % is remainder
        a = temp;
    }
    return a;
}

public static long max(long x, long y, long z){
		if(x>=y && x>=z) return x;
		if(y>=x && y>=z) return y;
		return z;
	}
	static int[] sieve(int n,int[] arr)
	{
	for(int i=2;i*i<=n;i++)
	{
		if(arr[i]==0)
		{
			for(int j=i*2;j<=n;j+=i)
				arr[j]=1;
		}
	}
	return arr;
	}

static class InputReader {

private final InputStream stream;
private final byte[] buf = new byte[8192];
private int curChar, snumChars;
private SpaceCharFilter filter;

public InputReader(InputStream stream) {
  this.stream = stream;
}

public int snext() {
  if (snumChars == -1)
    throw new InputMismatchException();
  if (curChar >= snumChars) {
    curChar = 0;
    try {
      snumChars = stream.read(buf);
    } catch (IOException e) {
      throw new InputMismatchException();
    }
    if (snumChars <= 0)
      return -1;
  }
  return buf[curChar++];
}

public int nextInt() {
  int c = snext();
  while (isSpaceChar(c)) {
    c = snext();
  }
  int sgn = 1;
  if (c == '-') {
    sgn = -1;
    c = snext();
  }
  int res = 0;
  do {
    if (c < '0' || c > '9')
      throw new InputMismatchException();
    res *= 10;
    res += c - '0';
    c = snext();
  } while (!isSpaceChar(c));
  return res * sgn;
}

public long nextLong() {
  int c = snext();
  while (isSpaceChar(c)) {
    c = snext();
  }
  int sgn = 1;
  if (c == '-') {
    sgn = -1;
    c = snext();
  }
  long res = 0;
  do {
    if (c < '0' || c > '9')
      throw new InputMismatchException();
    res *= 10;
    res += c - '0';
    c = snext();
  } while (!isSpaceChar(c));
  return res * sgn;
}

public int[] nextIntArray(int n) {
	 return nextIntArray(n, 0);
	    }

public int[] nextIntArray(int n, int off) {
	 int[] arr = new int[n + off];
	   for (int i = 0; i < n; i++) {
	    arr[i + off] = nextInt();
	    }
	    return arr;
	    }

public long[] nextLongArray(int n) {
return nextLongArray(n, 0);
	    }

	public long[] nextLongArray(int n, int off) {
	 long[] arr = new long[n + off];
	 for (int i = 0; i < n; i++) {
		  arr[i + off] = nextLong();
		 }
 return arr;
	}

public String readString() {
  int c = snext();
  while (isSpaceChar(c)) {
    c = snext();
  }
  StringBuilder res = new StringBuilder();
  do {
    res.appendCodePoint(c);
    c = snext();
  } while (!isSpaceChar(c));
  return res.toString();
}

public String nextLine() {
  int c = snext();
  while (isSpaceChar(c))
    c = snext();
  StringBuilder res = new StringBuilder();
  do {
    res.appendCodePoint(c);
    c = snext();
  } while (!isEndOfLine(c));
  return res.toString();
}

public boolean isSpaceChar(int c) {
  if (filter != null)
    return filter.isSpaceChar(c);
  return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}

private boolean isEndOfLine(int c) {
  return c == '\n' || c == '\r' || c == -1;
}

public interface SpaceCharFilter {
  public boolean isSpaceChar(int ch);
}
}

}

import java.util.Scanner;
import java.io.PrintWriter;

public class ArpaAndResearchInMexicanWave{
    public static void main(String args[]){
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = in.nextInt();
		int k = in.nextInt();
		int t = in.nextInt();

		if(t <= k){
			System.out.print(t);
		}
        else if(k<t && t<=n){
			System.out.print(k);
		}
        else
			System.out.print(Math.min(k,n+k-t));

        System.out.close();
    }
}

import java.util.Scanner;

public class _851A {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int t = sc.nextInt();
       if(t>=k && t<=n) System.out.println(k);
       else if(t<k) System.out.println(t);
       else System.out.println(k-(t-n));

    }
}

import java.util.*;
public class ProblemA {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long k = sc.nextLong();
		long t = sc.nextLong();

		if(t<=k){
			System.out.println(t);
		}
		else{
			if(t<=n){
				System.out.println(k);
			}
			else{
				System.out.println(n+k-t);
			}
		}

	}

}

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class ArpaAndAresearchInMexicanWave {
	public static void main(String []args) throws Exception{
		BufferedReader br=new BufferedReader(new InputStreamReader (System.in));
		String s=br.readLine();
		String[]sa=s.split(" ");
		long n=Long.parseLong(sa[0]);
		long k=Long.parseLong(sa[1]);
		long t=Long.parseLong(sa[2]);
		long ans=0;
		if(t<=k) {
			ans=t;
		}
		else if(t>=n+k){
			k=0;
		}
		else{
			if(k-(t-n)>k)
			ans=k;
			else
				ans=k-(t-n);
		}
		if(k>-1)
			System.out.println(ans);
		else
			System.out.println(0);
	}
}

import java.util.Scanner;
public class tamrini {
public static void main(String[] args) {
	Scanner scanner = new Scanner (System.in);
	int a = scanner.nextInt();
	int b = scanner.nextInt();
	int c = scanner.nextInt();
	int z = Math.min(a+b-c, c);
	if (z>b) z=b;
	System.out.println(z);
	scanner.close();
}
}

import java.util.Scanner;

public class Solution {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		long n = s.nextLong();
		long k = s.nextLong();
		long t = s.nextLong();
		long a = 0;

		if (t <= k) {
			a = t;
		} else if (t > n) {
			a = Math.abs(n - t);
			a = Math.abs(a - k);
		} else {
			a = k;
		}

		System.out.println(a);
	}
}

import java.io.*;
import java.util.*;

public class Main {

    static StringBuilder data = new StringBuilder();
    final static FastReader in = new FastReader();

    public static void main(String[] args) {
       int n=in.nextInt(),k=in.nextInt(),t=in.nextInt();
        if(t<k){
            System.out.println(t);
        }else if (t>n){
            System.out.println(k-(t%n));
        }else{
            System.out.println(k);
        }
    }

    static void fileOut(String s) {
        File out = new File("output.txt");
        try {
            FileWriter fw = new FileWriter(out);
            fw.write(s);
            fw.flush();
            fw.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        public FastReader(String path) {
            try {
                br = new BufferedReader(new
                        InputStreamReader(new FileInputStream(path)));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        float nextFloat() {
            return Float.parseFloat(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        long n = s.nextLong();
        long k = s.nextLong();
        long t = s.nextLong();
        if(t<n&&t<k){
            System.out.println(t);
        }else if(t<n && t>=k){
            System.out.println(k);
        }else{
            System.out.println((n+k)-t);
        }
    }
    }

import java.io.BufferedInputStream;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(new BufferedInputStream(System.in));
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int t = scanner.nextInt();
        if(t <= k) System.out.println(t);
        else if(t > k && t<=n) System.out.println(k);
        else System.out.println(k - (t-n));
    }
}

import java.io.*;
public class sample{
	public static void main(String[] args) throws IOException
	{
		BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
		int n,k,t;
		String str[]=input.readLine().split(" ");
		n=Integer.parseInt(str[0]);
		k=Integer.parseInt(str[1]);
		t=Integer.parseInt(str[2]);
		if(t<k)System.out.println(t);
		else if(k<=t && t<=n)System.out.println(k);
		else System.out.println(k-(t-n));
	}
}

import java.util.Scanner;

/**
 *
 * @author mustafa
 */
public class A {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int k = sc.nextInt();
        int t = sc.nextInt();

        if (t < k)
            System.out.println(t);
        else{
            if(t >= k && t <= n)
                System.out.println(k);
            else
                System.out.println(n + k - t);
        }
    }
}

import java.io.*;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), k = in.nextInt(), t = in.nextInt();
        if (t < k) System.out.println(t);
        else if (t <= n && k <= t) System.out.println(k);
        else System.out.println(n-t+k);
    }
}

import java.util.*;
public class ArpaAndMexicanwave {
	public static void main (String [] args){
		Scanner input=new Scanner(System.in);
		int n=input.nextInt();
		int k=input.nextInt();
		int t=input.nextInt();
		int num=0;

		if(t<k){
			num=t;
		}
		else if((t>=k)&&(t<=n)){
			num=k;
		}
		else{
			int mod=t%n;
			num=Math.abs(k-mod);
		}
		System.out.println(num);
	}
}

import java.util.Scanner;

public class JavaApplication42
{

    public static void main(String[] args)
    {

        Scanner input = new Scanner(System.in);

            System.out.print("");
                int n = input.nextInt();
                int k = input.nextInt();
                int t = input.nextInt();

            if ( k <= t & t <= n)
                System.out.println(k);
            if ( t < k )
                System.out.println(t);
            if ( t > n )
                System.out.println(n+k-t);

    }

}

import java.util.*;
public class Arpa {

    public static void main(String[] args) {
       Scanner input=new Scanner(System.in);
        int n,k,t;
        n=input.nextInt();
        k=input.nextInt();
        t=input.nextInt();
        if(k>=t)
            System.out.println(t);
        else if (t>k && n>=t)
            System.out.println(k);
        else
            System.out.println(k-t+n);

    }

}

import java.util.*;
public class JavaApplication7 {
 public static void main(String[] args) {
  Scanner obj = new Scanner(System.in);
  long [] arr = new long [3];
  for(int i=0 ; i<3; i ++)  arr[i]=obj.nextLong();
  if(arr[2]<=arr[1])
      System.out.println(arr[2]);
  else if (arr[2]<=(arr[0]))
      System.out.println(arr[1]);
  else{
      long n=arr[2]-arr[0];
      System.out.println(Math.abs(n-arr[1]));
  }
 }}

import java.util.Scanner;
import java.io.PrintWriter;

public class ArpaAndResearchInMexicanWave{
    public static void main(String args[]){
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = in.nextInt();
		int k = in.nextInt();
		int t = in.nextInt();

		if(t <= k){
			System.out.print(t);
		}
        else if(k<t && t<=n){
			System.out.print(k);
		}
        else
			System.out.print(Math.min(k,n+k-t));

        System.out.close();
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastInput in = new FastInput(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastInput in, PrintWriter out) {
            long n = in.nextLong();
            long k = in.nextLong();
            long t = in.nextLong();

            if (t <= k) {
                out.print(t);
                return;
            }

            if (t >= k && t <= n) {
                out.print(k);
                return;
            }

            out.print(n + k - t);
        }

    }

    static class FastInput {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public FastInput(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}

import java.util.*;
public class ProblemA {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long k = sc.nextLong();
		long t = sc.nextLong();

		if(t<=k){
			System.out.println(t);
		}
		else{
			if(t<=n){
				System.out.println(k);
			}
			else{
				System.out.println(n+k-t);
			}
		}

	}

}

import java.util.Scanner;
public class Maratona1 {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        long n = s.nextLong();
        long k = s.nextLong();
        long t = s.nextLong();
        if(t<n&&t<k){
            System.out.println(t);
        }else if(t<n && t>=k){
            System.out.println(k);
        }else{
            System.out.println((n+k)-t);
        }
    }
    }
// 1507984414832

/**
 * @author Siddhraj Sisodiya
 */

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA
    {
        public void solve(int testNumber, InputReader in, OutputWriter out)
        {
            int n = in.nextInt(), k = in.nextInt(), t = in.nextInt();

            if (t <= k)
            {
                out.println(t);
            } else if (t <= n)
            {
                out.println(k);
            } else
            {
                out.println(n + k - t);
            }

        }

    }

    static class InputReader
    {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream)
        {
            this.stream = stream;
        }

        public int read()
        {
            if (numChars == -1)
            {
                throw new InputMismatchException();
            }
            if (curChar >= numChars)
            {
                curChar = 0;
                try
                {
                    numChars = stream.read(buf);
                } catch (IOException e)
                {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt()
        {
            int c = read();
            while (isSpaceChar(c))
            {
                c = read();
            }
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do
            {
                if (c < '0' || c > '9')
                {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c)
        {
            if (filter != null)
            {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c)
        {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter
        {
            public boolean isSpaceChar(int ch);

        }

    }

    static class OutputWriter
    {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream)
        {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer)
        {
            this.writer = new PrintWriter(writer);
        }

        public void close()
        {
            writer.close();
        }

        public void println(int i)
        {
            writer.println(i);
        }

    }
}

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Team {

    public static void main(String[] args) {
        Scanner input=new Scanner(System.in);
        int n=input.nextInt();
        int k=input.nextInt();
        int t=input.nextInt();
        if (t<=k){
            System.out.println(t);
        }
        else if (t>=k+1&&t<=k+(n-k)){
            System.out.println(k);
        }
        else{
            System.out.println(k-(t-n));
        }

   }
}

import java.util.*;
public class Wave
{
    public static void main(String args[])
    throws Exception
    {
        Scanner scan=new Scanner(System.in);
        long n=scan.nextLong();
        long k=scan.nextLong();
        long t=scan.nextLong();
        long stand=0;
            if(t<=k)
            {
            stand=t;
        }
            else if(t>=k && t<=n)
            {
            stand=k;
        }
            else
            {
            stand=(n+k-t);
        }
        System.out.print(stand);
    }
}

        import java.util.Scanner;

public class MexicanWave
{
        public static void main ( String [] args )
        {
                Scanner Input = new Scanner( System.in ) ;
                int Total = Input.nextInt ( ) ;
                int Wave = Input.nextInt ( ) ;
                int Time = Input.nextInt ( ) ;
                if ( Time <= Wave )
                {
                        System.out.println ( Time ) ;
                }
                else if ( Total >= Time && Time >= Wave )
                {
                        System.out.println ( Wave ) ;
                }
                else
                {
                        System.out.println ( ( Wave + Total ) % Time ) ;
                }
        }
}

import java.util.*;

public class Code{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		int t=sc.nextInt();
		int output;
		if(t<=k)
			output=t;
		else if(t>k && t<=n)
			output=k;
		else
			output=k+n-t;
		System.out.println(output);
	}
}

import java.util.*;

public class TeClass {
    public static int factorial;
    public static void main(String args[] ) throws Exception {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k= sc.nextInt();
        int t= sc.nextInt();
        int sum = 0;
        if(t>=n)
        System.out.println(n+k-t);
        else if(n>t&&k<=t)
        System.out.println(k);
        else if(n>t&&k>t)
        System.out.println(t);
    }
}

import java.math.BigInteger;
import java.util.*;
import java.io.*;
import java.text.*;

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 32768);
    static PrintWriter out = new PrintWriter(System.out);
    static StringTokenizer t;

    static String sn() {
        while (t == null || !t.hasMoreTokens()) {
            try {
                t = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }
        return t.nextToken();
    }

    static int ni() {
        return Integer.parseInt(sn());
    }

    static long nlo() {
        return Long.parseLong(sn());
    }

    static long mod = (long) 1000000007;

    static long pro(long a, long b) {
        return (a % mod * b % mod) % mod;
    }

    static long add(long a, long b) {
        return (a + b) % mod;
    }

    static long sub(long a, long b) {
        return ((a % mod - b % mod) + mod) % mod;
    }

    static int pow(int n) {
        return (int) (Math.log10(n) / Math.log10(2));
    }

    static long modpow(long x, long y) {
        long res = 1;
        x %= mod;
        while (y > 0) {
            if (y % 2 != 0)
                res = pro(res, x);
            x = pro(x, x);
            y /= 2;
        }
        return res;
    }

//    static class pair {
//        String a;
//        int b;
//
//        pair(String x, int y) {
//            a = x;
//            b = y;
//        }
//    }

    static long modInverse(long n) {
        BigInteger n1 = new BigInteger(Long.toString(n));
        String s = (n1.modInverse(new BigInteger(Long.toString(mod)))).toString();
        return Long.parseLong(s) % mod;
    }

    static boolean v[] = new boolean[1000005];

    static void seive() {
        v[1] = true;
        for (int i = 2; i < 1000005; i++) {
            if (!v[i]) {
                for (int j = 2 * i; j < 1000005; j += i)
                    v[j] = true;
            }
        }
    }

    static boolean isprime(long n) {
        if (n == 1)
            return false;
        for (int i = 2; i * i <= n; i++) {
            if (n % i == 0)
                return false;
        }
        return true;
    }

    static int gcd(int a, int b) {
        if (b == 0)
            return a;
        return gcd(b, a % b);
    }

    static DecimalFormat df = new DecimalFormat("0.00000000000");

    static class trie {
        trie a[] = new trie[26];
        int cnt = 0;
    }

    static int maxn = (int) 3e5 + 5;

    static long gcd(long a, long b) {
        if (b == 0)
            return a;
        else
            return gcd(b, a % b);
    }

    static void solve() {
        long n = nlo();
        int k = ni();
        int t = ni();
        if (t <= k)
            out.println(t);
        else if (t > k && t <= n)
            out.println(k);
        else if (t > n)
            out.println(k-t+n);
    }

    public static void main(String args[]) {
        int t = 1;
        while (t-- > 0) {
            solve();
        }
        out.close();
    }
}

import java.util.Scanner;

public class Codeforces851A {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		int n=scan.nextInt();
		int k=scan.nextInt();
		int t=scan.nextInt();

		if(t<=n && t > k) {
			System.out.println(k);
		} else if (t<=k) {
			System.out.println(t);
		} else {
			System.out.println((n+k)-t);

		}

	}

}

import java.io.*;

import java.util.*;
/**
 *
 * @author Aaryan
 * AV
 */
public class Test {
   /* package codechef; // don't place package name! */

    public static void main (String[] args) throws java.lang.Exception{

    PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	String p[] = br.readLine().split(" ");
        int n = Integer.parseInt(p[0]);
        int k = Integer.parseInt(p[1]);
        int t = Integer.parseInt(p[2]);
	int min1=Math.min(k,n+k-t);

	out.println(Math.min(t,min1));
        out.flush();

    }

     }

import java.io.*;
import java.util.*;

public class A {

	public static void main(String[] args) {
		FastScannerA sc = new FastScannerA(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();
		int T = sc.nextInt();

		if(T <= K){
			System.out.println(T);
		}
		else if(T <= N){
			System.out.println(K);
		}
		else{
			System.out.println(K - (T - N) );
		}

	}
}

class FastScannerA{
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;

    public FastScannerA(InputStream stream)
    {
        this.stream = stream;
    }

    public int read()
    {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars)
        {
            curChar = 0;
            try
            {
                numChars = stream.read(buf);
            } catch (IOException e)
            {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int nextInt()
    {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-')
        {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do
        {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public String next()
    {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do
        {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    public String nextLine()
    {
        int c = read();
        StringBuilder res = new StringBuilder();
        do
        {
            res.appendCodePoint(c);
            c = read();
        } while (!isLineEndChar(c));
        return res.toString();
    }

    public double nextDouble() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        double res = 0;
        while (!isSpaceChar(c) && c != '.') {
            if (c == 'e' || c == 'E')
                return res * Math.pow(10, nextInt());
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        }
        if (c == '.') {
            c = read();
            double m = 1;
            while (!isSpaceChar(c)) {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                m /= 10;
                res += (c - '0') * m;
                c = read();
            }
        }
        return res * sgn;
    }

    public long nextLong() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public boolean isSpaceChar(int c)
    {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public boolean isLineEndChar(int c)
    {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == '\n' || c == '\r' || c == -1;
    }

    public interface SpaceCharFilter
    {
        public boolean isSpaceChar(int ch);
    }
}

import java.util.Scanner;
public class cf851A {

	public static void main(String[] args) {
		System.out.println();
		Scanner scan = new Scanner(System.in);
		while(scan.hasNextInt()){
			int n,k,t;
			n = scan.nextInt();
			k = scan.nextInt();
			t = scan.nextInt();
			if(t < k){
				System.out.println(t);
				continue;
			}
			if(t<=n){
				System.out.println(k);
				continue;
			}
			System.out.println(k-(t-n));
		}

	}

}

import java.util.Scanner;
public class main{
	public static void main(String[]args){
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int k = input.nextInt();
		int t = input.nextInt();
		int res = 0;
		if(n>=t && k>=t){
			res = t;
		}
		else if(n>=t && k<t){
			res = k;
		}
		else if(n<t){
			res = (t-n)-k;
		}
		if(res < 0){
			res*=-1;
		}
		System.out.println(res);
	}
}

// 1508124682081

import java.util.Scanner;

/**
 * Created by phuoc on 9/1/17.
 */
public class A_432 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        int t = in.nextInt();
        if (t <= k) {
            System.out.println(t);
        } else if (t >= n) {
            System.out.println(n + k - t);
        } else System.out.println(k);
    }
}

import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigDecimal;

public class R432B {
    public static void main (String[] args) throws java.lang.Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter w = new PrintWriter(System.out);
        long n = in.nextLong(), k = in.nextLong(), t = in.nextLong();
        if (t < k)
            w.println(t);
        else if (t >= k && t <= n)
            w.println(k);
        else
            w.println(k - (t % n));

        w.close();
    }

}

import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;

/**
 * Created by fly on 9/4/17.
 */
public class Main {
    public static int mod = 1000000007;

    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));

        int n = in.nextInt();
        int l = in.nextInt();
        int t = in.nextInt();
        if(t <= l) {
            System.out.println(t);
        } else if(t >n) {
            System.out.println(Math.max(n+l-t, 0));
        } else {
            System.out.println(l);
        }
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
}

import java.util.Scanner;
public class MexicanWave {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int spectators = sc.nextInt();
		int position = sc.nextInt();
		int time = sc.nextInt();

		if (time <= position) {

			System.out.println(time);

		} else if (time > position && time <= spectators) {

			System.out.println(position);

		} else {

			System.out.println(spectators + position - time);

		}
	}

}

import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		if(c==0) {
			System.out.print(0);
		}else {
			if(c<=b)
				System.out.print(c);
			else if(c>a)
				System.out.print(b-(c-a));
			else
				System.out.print(b);
		}
	}
}

import java.util.Scanner;
import java.io.PrintWriter;

public class Code_851A_ArpaAndResearchInMexicanWave{
    public static void main(String args[]){
        Scanner in=new Scanner(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n=in.nextInt(),k=in.nextInt(),t=in.nextInt();
        if(t<=k)out.print(t);
        else if(k<t && t<=n)out.print(k);
        else out.print(Math.min(k,n+k-t));

        out.close();
    }
}

import java.util.Scanner;
public class Maratona1 {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        long n = s.nextLong();
        long k = s.nextLong();
        long t = s.nextLong();
        if(t<n&&t<k){
            System.out.println(t);
        }else if(t<n && t>=k){
            System.out.println(k);
        }else{
            System.out.println((n+k)-t);
        }
    }
    }
// 1507984414832

import java.util.*;
public class A851
{
	public static void main(String[] args)
	{
		int i,j,n,k,t,stand=0;
		Scanner sc=new Scanner(System.in);
		n=sc.nextInt();
		k=sc.nextInt();
		t=sc.nextInt();
		if(t<=k)
			stand=t;
		else if(t>k&&t<=n)
			stand=k;
		else
			stand=k-(t-n);
		System.out.println(stand);
	}
}

import java.util.Scanner;

public class Leetcode {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt(), k = scan.nextInt(), t = scan.nextInt();
		scan.close();
		if (t <= k) {
			System.out.println(t);
		} else if (t > k && t <= n) {
			System.out.println(k);
		} else {
			System.out.println(k - (t - n));
		}
	}
}

import java.util.*;

public final class Mine {
	Scanner sc;
	public static void main(String [] args) {
		new Mine().run();
	}

	public void run() {
		this.sc = new Scanner(System.in);
		long s = System.currentTimeMillis();
		solve();
		//System.out.println(System.currentTimeMillis()-s + "-ms");
	}

	public void solve() {
		int n = sc.nextInt();
		int k = sc.nextInt();
		int t = sc.nextInt();
		int i = 0;
		if (t < k) {
			i = t;
		} else if (t <= n) {
			i = k;
		} else {
			i = k - (t-n);
		}
		System.out.println(i);
	}

}

import java.io.*;
public class sample{
	public static void main(String[] args) throws IOException
	{
		BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
		int n,k,t;
		String str[]=input.readLine().split(" ");
		n=Integer.parseInt(str[0]);
		k=Integer.parseInt(str[1]);
		t=Integer.parseInt(str[2]);
		if(t<k)System.out.println(t);
		else if(k<=t && t<=n)System.out.println(k);
		else System.out.println(k-(t-n));
	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastInput in = new FastInput(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastInput in, PrintWriter out) {
            long n = in.nextInt();
            long k = in.nextInt();
            long t = in.nextInt();

            if (t <= k) {
                out.print(t);
                return;
            }

            if (t - k <= k) {
                out.print(k);
                return;
            }

            out.print(n + k - t);
        }

    }

    static class FastInput {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public FastInput(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;

/**
 *
 * @author Fuad
 */
//1 4 5 6
public class Codeforces {

    static class pair<T1, T2> implements Comparator {

        T1 first;
        T2 second;

        pair(T1 f, T2 s) {
            first = f;
            second = s;
        }

        pair() {

        }

        @Override
        public int compare(Object o1, Object o2) {
            pair<Integer, Integer> p1 = (pair) o1;
            pair<Integer, Integer> p2 = (pair) o2;

            if (p1.first < p2.first) {
                return -1;
            } else if (p2.first < p1.first) {
                return 1;
            } else {
                return p1.second <= p2.second ? -1 : 1;
            }
        }

    }

    public static void main(String[] args) throws Exception {
        // TODO code application logic here

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String inp[];
        StringBuilder sol = new StringBuilder();
        int n, k, t;

        inp = br.readLine().split(" ");
        n = Integer.parseInt(inp[0]);
        k = Integer.parseInt(inp[1]);
        t = Integer.parseInt(inp[2]);

        if(t <= k){
            System.out.println(t);
        }else if( t<= n){
            System.err.println(k);
        }else{
            System.out.println(k - (t-n));
        }

    }

}

import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;

/**
 * Created by fly on 9/4/17.
 */
public class Main {
    public static int mod = 1000000007;

    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));

        int n = in.nextInt();
        int l = in.nextInt();
        int t = in.nextInt();
        if(t <= l) {
            System.out.println(t);
        } else if(t >n) {
            System.out.println(Math.max(t - l + n, 0));
        } else {
            System.out.println(l);
        }
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
}

//package mexican.wave;

import java.util.Scanner;

public class MexicanWave {

    public static void main(String[] args) {
        Scanner in =new Scanner(System.in);
        int n=in.nextInt();
        int k=in.nextInt();
        int t=in.nextInt();
        int ans=0;
        if(t==0)
            ans=0;
        else if(t%(n+k) == 0)
            ans=0;
        else if(t<=k){
            ans=(k);
            //if(ans==0)
              //  ans=k;
        }
        else if(t<=n)
            ans=k;
        else if(t>n)
            ans=k-(t%n);
        System.out.print(ans);
    }
}

/**
 * @author Siddhraj Sisodiya
 */

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA
    {
        public void solve(int testNumber, InputReader in, OutputWriter out)
        {
            int n = in.nextInt(), k = in.nextInt(), t = in.nextInt();

            if (t <= k)
            {
                out.println(t);
            } else if (t <= n + 1)
            {
                out.println(k);
            } else
            {
                out.println(n + k - t);
            }

        }

    }

    static class InputReader
    {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream)
        {
            this.stream = stream;
        }

        public int read()
        {
            if (numChars == -1)
            {
                throw new InputMismatchException();
            }
            if (curChar >= numChars)
            {
                curChar = 0;
                try
                {
                    numChars = stream.read(buf);
                } catch (IOException e)
                {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt()
        {
            int c = read();
            while (isSpaceChar(c))
            {
                c = read();
            }
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do
            {
                if (c < '0' || c > '9')
                {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c)
        {
            if (filter != null)
            {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c)
        {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter
        {
            public boolean isSpaceChar(int ch);

        }

    }

    static class OutputWriter
    {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream)
        {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer)
        {
            this.writer = new PrintWriter(writer);
        }

        public void close()
        {
            writer.close();
        }

        public void println(int i)
        {
            writer.println(i);
        }

    }
}

/**
 * @author Siddhraj Sisodiya
 */

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA
    {
        public void solve(int testNumber, InputReader in, OutputWriter out)
        {
            int n = in.nextInt(), k = in.nextInt(), t = in.nextInt();

            if (t <= k)
            {
                out.println(t);
            } else if (t <= n + 1)
            {
                out.println(k);
            } else
            {
                out.println(t - n + 1);
            }

        }

    }

    static class InputReader
    {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream)
        {
            this.stream = stream;
        }

        public int read()
        {
            if (numChars == -1)
            {
                throw new InputMismatchException();
            }
            if (curChar >= numChars)
            {
                curChar = 0;
                try
                {
                    numChars = stream.read(buf);
                } catch (IOException e)
                {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt()
        {
            int c = read();
            while (isSpaceChar(c))
            {
                c = read();
            }
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do
            {
                if (c < '0' || c > '9')
                {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c)
        {
            if (filter != null)
            {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c)
        {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter
        {
            public boolean isSpaceChar(int ch);

        }

    }

    static class OutputWriter
    {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream)
        {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer)
        {
            this.writer = new PrintWriter(writer);
        }

        public void close()
        {
            writer.close();
        }

        public void println(int i)
        {
            writer.println(i);
        }

    }
}

import java.io.*;
import java.util.*;

public class Main {
    static final String fileName = "LLIAMA3OB";

    static void solutionA() {
        int n = fs.nextInt(), k = fs.nextInt(), t = fs.nextInt();
        if (t < k) {pw.print(t);
        return;}
        if (t < n - k) {
            pw.print(k);
            return;
        }
        pw.print(n + k - t);
    }

    static void solutionB() {
        long ax = fs.nextInt(), ay = fs.nextInt(),bx = fs.nextInt(),by = fs.nextInt(), cx = fs.nextInt(), cy = fs.nextInt(), x1 = ax - bx, x2 = bx - cx, y1 = ay - by, y2 = by - cy;
        if (((x1*x1 + y1*y1) == (x2*x2 + y2*y2)) && (x1*y2 != x2*y1)){
            pw.print("Yes");
        } else {
            pw.print("No");
        }
    }

    public static void main(String[] args) {
        try {
            fs = new FastScanner(new FileInputStream(fileName + ".in"));
            pw = new PrintWriter(new BufferedOutputStream(new FileOutputStream(fileName + ".out")));
        } catch (IOException e) {
            fs = new FastScanner(System.in);
            pw = new PrintWriter(new BufferedOutputStream(System.out));
        }
        solutionA();
        pw.close();
    }

    static PrintWriter pw;
    static FastScanner fs;

    static class FastScanner {
        BufferedReader br;
        StringTokenizer tokenizer;

        public FastScanner(InputStream stream) {
            br = new BufferedReader(new InputStreamReader(stream));
        }

        private String readLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        public String nextToken() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(readLine());
            }
            return tokenizer.nextToken();
        }

        public byte nextByte() {
            return Byte.parseByte(nextToken());
        }

        public short nextShort() {
            return Short.parseShort(nextToken());
        }

        public int nextInt() {
            return Integer.parseInt(nextToken());
        }

        public long nextLong() {
            return Long.parseLong(nextToken());
        }

        public double nextDouble() {
            return Double.parseDouble(nextToken());
        }

        public boolean hasMoreTokens() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                String s = readLine();
                if (s == null) {
                    return false;
                }
                tokenizer = new StringTokenizer(readLine());
            }
            return tokenizer.hasMoreTokens();
        }
    }
}

import java.util.*;

 // Compiler version JDK 11.0.2

 public class Dcoder
 {
   public static void main(String args[])
   {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int k=sc.nextInt();
    int t=sc.nextInt();
    if(t<k-1){
      System. out. println(t);
    }else if(k <= t && t <=n ){
      System. out. println(k);
    }else if(t > k && t < k+n){
      int x=t-n+1;
      System. out. println(x);
    }
   }
 }

import java.util.*;

 // Compiler version JDK 11.0.2

 public class Dcoder
 {
   public static void main(String args[])
   {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int k=sc.nextInt();
    int t=sc.nextInt();
    if(t<k-1){
      System. out. println(t);
    }else if(k <= t && t <=n ){
      System. out. println(k);
    }else if(t > k && t < k+n){
      int x=t-n;
      System. out. println(x);
    }
   }
 }

// 432

import java.util.*;
import java.io.*;

public class Main{

	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int numCase = 1;
		String l = "";
		while((l = br.readLine()) != null){
			String[] line = l.split(" ");
			int n = Integer.parseInt(line[0]);
			int k = Integer.parseInt(line[1]);
			int t = Integer.parseInt(line[2]);

			if(t < k)
				System.out.println(t);
			else if(t > n)
				System.out.println((t - n + 1));
			else
				System.out.println(k);

			numCase++;
		}

		br.close();
	}

}

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.InputMismatchException;
import java.util.Scanner;
import java.util.TreeSet;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.Math;
import java.math.BigInteger;

public class j7 implements Runnable {

	public void run(){
		InputReader in =  new InputReader(System.in);
		PrintWriter w = new PrintWriter(System.out);
		long n=in.nextLong();
		long k=in.nextLong();
		long t=in.nextLong();
		if(t<=k)
			w.println(t);
		else
			w.println(n+k-t);
		w.close();

	}

	static class InputReader {

		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream)
		{
			this.stream = stream;
		}

		public int read()
		{
			if (numChars==-1)
				throw new InputMismatchException();

			if (curChar >= numChars)
			{
				curChar = 0;
				try
				{
					numChars = stream.read(buf);
				}
				catch (IOException e)
				{
					throw new InputMismatchException();
				}

				if(numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public String nextLine()
		{
			BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
			String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
		}
		public int nextInt()
		{
			int c = read();

			while(isSpaceChar(c))
				c = read();

			int sgn = 1;

			if (c == '-')
			{
				sgn = -1;
				c = read();
			}

			int res = 0;
			do
			{
				if(c<'0'||c>'9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			while (!isSpaceChar(c));

			return res * sgn;
		}

		public long nextLong()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = read();
			}
			long res = 0;

			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			while (!isSpaceChar(c));
				return res * sgn;
		}

		public double nextDouble()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = read();
			}
			double res = 0;
			while (!isSpaceChar(c) && c != '.')
			{
				if (c == 'e' || c == 'E')
					return res * Math.pow(10, nextInt());
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			if (c == '.')
			{
				c = read();
				double m = 1;
				while (!isSpaceChar(c))
				{
					if (c == 'e' || c == 'E')
						return res * Math.pow(10, nextInt());
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					m /= 10;
					res += (c - '0') * m;
					c = read();
				}
			}
			return res * sgn;
		}

		public String readString()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = read();
			}
			while (!isSpaceChar(c));

			return res.toString();
		}

		public boolean isSpaceChar(int c)
		{
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public String next()
		{
			return readString();
		}

		public interface SpaceCharFilter
		{
			public boolean isSpaceChar(int ch);
		}
	}

	public static void main(String args[]) throws Exception
	{
		new Thread(null, new j7(),"j7",1<<26).start();
	}
 }

import java.util.Scanner;

public class MexicanWave {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int k = s.nextInt();
		int t = s.nextInt();
		if (t - (n+k) > 0) {
			System.out.println(k - (t - (n+k)));
		} else {
			System.out.println(Math.min(t, k));
		}
		s.close();
	}
}

import java.util.Scanner;

public class MexicanWave {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int k = s.nextInt();
		int t = s.nextInt();
		if (t - (n+k) > 0) {
			System.out.println(t - (n+k));
		} else {
			System.out.println(Math.min(t, k));
		}
	}
}

import java.util.*;
public class ArpaMexican {
	public static int mexican(int n, int k, int t) {
		if (t<k) {
			return t;
		} else if (t>n) {
			return (t-n+1);
		} else {
			return k;
		}
	}
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String s1 = s.nextLine();
		String[] s2 = s1.split(" ");
		int n,k,t;
		n = Integer.parseInt(s2[0]);
		k = Integer.parseInt(s2[1]);
		t = Integer.parseInt(s2[2]);
		System.out.println(mexican(n,k,t));
	}
}

import java.util.*;
public class ArpaMexican {
	public static int mexican(int n, int k, int t) {
		if (t<k) {
			return t;
		} else if (t>n) {
			return Math.max((t-n+1),0);
		} else {
			return k;
		}
	}
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String s1 = s.nextLine();
		String[] s2 = s1.split(" ");
		int n,k,t;
		n = Integer.parseInt(s2[0]);
		k = Integer.parseInt(s2[1]);
		t = Integer.parseInt(s2[2]);
		System.out.println(mexican(n,k,t));
	}
}

import java.util.*;
public class ArpaMexican {
	public static int mexican(int n, int k, int t) {
		if (t<=k) {
			return t;
		} else if (t>n) {
			return Math.max((t-n+1),0);
		} else {
			return k;
		}
	}
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String s1 = s.nextLine();
		String[] s2 = s1.split(" ");
		int n,k,t;
		n = Integer.parseInt(s2[0]);
		k = Integer.parseInt(s2[1]);
		t = Integer.parseInt(s2[2]);
		System.out.println(mexican(n,k,t));
	}
}

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;
import java.util.ArrayList;
import java.util.PriorityQueue;

public class Solution
{

    /*--------------solution--------------*/ //PROBABLY WRONG LOL
    public static void main(String[] args)
    {
        Reader in = new Reader(System.in);
        PrintWriter out = new PrintWriter(System.out);

       int n = in.nextInt() ,
               k = in.nextInt() ,
               t = in.nextInt() , ans = 0;

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

        out.println(ans);
        out.close();
    }
    /*--------------solution--------------*/

    ///////////////////////////////////////////////////////////////////////////////////

    /*------------fast io------------*/
    static class Reader
    {

        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public Reader(InputStream in)
        {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next()
        {
            while(tokenizer == null || !tokenizer.hasMoreTokens())
            {
                try
                {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch(IOException e) {
                    e.printStackTrace();
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt()
        {
            return Integer.parseInt(next());
        }

    }
  /*------------fast io------------*/

}

import java.io.*;
import java.util.*;

public class Main {

    static StringBuilder data = new StringBuilder();
    final static FastReader in = new FastReader();

    public static void main(String[] args) {
       int n=in.nextInt(),k=in.nextInt(),t=in.nextInt();
        if(t<k){
            System.out.println(t);
        }else{
            System.out.println(k);
        }
    }

    static void fileOut(String s) {
        File out = new File("output.txt");
        try {
            FileWriter fw = new FileWriter(out);
            fw.write(s);
            fw.flush();
            fw.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        public FastReader(String path) {
            try {
                br = new BufferedReader(new
                        InputStreamReader(new FileInputStream(path)));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        float nextFloat() {
            return Float.parseFloat(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.StringTokenizer;

public class A {
	public static void main(String[] args) throws IOException {
		PrintWriter out = new PrintWriter(System.out);
		FastScanner in = new FastScanner(System.in);

		int n= in.nextInt();

	}

	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}

		public String next() throws IOException {
			if (!st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
				return next();
			}
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
		public double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
	}
}

import java.util.*;

public final class Mine {
	Scanner sc;
	public static void main(String [] args) {
		new Mine().run();
	}

	public void run() {
		this.sc = new Scanner(System.in);
		long s = System.currentTimeMillis();
		solve();
		System.out.println(System.currentTimeMillis()-s + "-ms");
	}

	public void solve() {
		int n = sc.nextInt();
		int k = sc.nextInt();
		int t = sc.nextInt();
		int i = 0;
		if (t < k) {
			i = t;
		} else if (t <= n) {
			i = k;
		} else {
			i = k - (t-n);
		}
		System.out.println(i);
	}

}

import java.util.Scanner;
public class spectator{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String spectators = scan.nextLine();
    String[] array = spectators.split(" ");
          int n = Integer.parseInt(array[0]);
          int k = Integer.parseInt(array[1]);
          int t = Integer.parseInt(array[2]);
    if(t>k && t<n) {
    	System.out.print(k);
    }
    else if(t<k && t<n) {
    	System.out.print(t);
    }
    else if(t>k && t>n) {
    	System.out.print(k-(t-n));
    }
  }
}

import java.util.Scanner;
public class spectator{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String spectators = scan.nextLine();
    String[] array = spectators.split(" ");
          int n = Integer.parseInt(array[0]);
          int k = Integer.parseInt(array[1]);
          int t = Integer.parseInt(array[2]);
    int counter = 0;
    int counterk = 0;
    while(counter!=t){
        if(counterk<k){
            counter++;
            counterk++;
        }
        else if(counter>n){
            counterk=counterk-2;
            counter++;
        }
        else{
            counter++;
        }
        System.out.print(counterk);
    }
    System.out.print(counterk);
  }
}

import java.util.Scanner;

public class arpa
{

    public static void main(String[] args)
    {

        Scanner input = new Scanner(System.in);

            System.out.print("");
            	int n = input.nextInt();
            	int k = input.nextInt();
            	int t = input.nextInt();

            if ( k <= t & t <= 2*k)
                System.out.println(k);
            if ( t < k )
                System.out.println(t);
            if ( t > 2*k )
                System.out.println(n+k-t);

    }

}

import java.util.Scanner;

public class arpa
{

    public static void main(String[] args)
    {

        Scanner input = new Scanner(System.in);

            System.out.print("");
            	int n = input.nextInt();
            	int k = input.nextInt();
            	int t = input.nextInt();

            if ( k <= t & t <= 2*k)
                System.out.println(k);
            if ( t < k )
                System.out.println(t);
            if ( t > 2*k )
                System.out.println(3*k-t);

    }

}

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class ArpaAndMexicanWave {

	public static void main(String[] args) {

		try{

			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			String in = reader.readLine();

			String inp[] = in.split(" ");
			int n = Integer.parseInt(inp[0]);
			int k = Integer.parseInt(inp[1]);
			int t = Integer.parseInt(inp[2]);

			if( t<=k)
			{
				System.out.println(t);
			}

			if(t>=k && t<=n)
			{
				System.out.println(k);
			}

			if(t>=n && t<=(n+k))
			{
				System.out.println(n+k-t);
			}

		}
		catch(Exception e)
		{
			e.printStackTrace();
		}

	}

}

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class ArpaAndMexicanWave {

	public static void main(String[] args) {

		try{

			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			String in = reader.readLine();

			String inp[] = in.split(" ");
			int n = Integer.parseInt(inp[0]);
			int k = Integer.parseInt(inp[1]);
			int t = Integer.parseInt(inp[2]);

			if( t<=k)
			{
				System.out.println(t);
			}

			if(t>=k && t<=n)
			{
				System.out.println(k);
			}

			if(t>=n && t<(n+k))
			{
				System.out.println(n+k-t);
			}

		}
		catch(Exception e)
		{
			e.printStackTrace();
		}

	}

}

import java.io.*;
import java.util.*;
import java.text.*;
import java.lang.*;
import java.math.BigInteger;
import java.util.regex.*;
public class Myclass {
	public static boolean visited[]=new boolean[300001];
	static ArrayList [] a=new ArrayList[300001];
	public static Vector<Integer>v=new Vector<>();
	public static void dfs(int n)
	{
		visited[n]=true;
		v.add(n);
		for(int i=0;i<a[n].size();i++)
		{
			int temp=(int) a[n].get(i);
			if(!visited[temp])
				dfs(temp);
		}
	}
	public static void main(String[] args)
	{
	    InputReader in = new InputReader(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		long n=in.nextLong();
		long k=in.nextLong();
		long t=in.nextLong();
		if(t<=k)
			pw.println(t);
		else if(t>k&& t<=2*k)
			pw.println(k);
		else
			pw.println(k-(t-n));

		pw.flush();
		pw.close();

	}

		static class InputReader
		{
		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream)
		{
			this.stream = stream;
		}
		public int snext()
		{
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars)
			{
				curChar = 0;
				try
				{
					snumChars = stream.read(buf);
				}
				catch (IOException e)
				{
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt()
	    {
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			int sgn = 1;
			if (c == '-')
		    {
				sgn = -1;
				c = snext();
			}
			int res = 0;
			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong()
	    {
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = snext();
			}
			long res = 0;
			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n)
		{
			int a[] = new int[n];
			for (int i = 0; i < n; i++)
			{
				a[i] = nextInt();
			}
			return a;
		}

		public String readString()
	    {
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = snext();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine()
		{
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = snext();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c)
		{
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c)
		{
			return c == '\n' || c == '\r' || c == -1;
		}

		public interface SpaceCharFilter
	    {
			public boolean isSpaceChar(int ch);
		}
	}
		public static long mod = 1000000007;
		public static int d;
		public static int p;
		public static int q;

		public static int[] suffle(int[] a,Random gen)
		{
			int n = a.length;
			for(int i=0;i<n;i++)
			{
				int ind = gen.nextInt(n-i)+i;
				int temp = a[ind];
				a[ind] = a[i];
				a[i] = temp;
			}
			return a;
		}

		public static void swap(int a, int b){
			int temp = a;
			a = b;
			b = temp;
		}

		public static HashSet<Integer> primeFactorization(int n)
		{
			HashSet<Integer> a =new HashSet<Integer>();
			for(int i=2;i*i<=n;i++)
			{
				while(n%i==0)
				{
					a.add(i);
					n/=i;
				}
			}
			if(n!=1)
				a.add(n);
			return a;
		}

		public static void sieve(boolean[] isPrime,int n)
		{
			for(int i=1;i<n;i++)
				isPrime[i] = true;

			isPrime[0] = false;
			isPrime[1] = false;

			for(int i=2;i*i<n;i++)
			{
				if(isPrime[i] == true)
				{
					for(int j=(2*i);j<n;j+=i)
						isPrime[j] = false;
				}
			}
		}

		public static int GCD(int a,int b)
		{
			if(b==0)
				return a;
			else
				return GCD(b,a%b);
		}

		public static long GCD(long a,long b)
		{
			if(b==0)
				return a;
			else
				return GCD(b,a%b);
		}

		public static void extendedEuclid(int A,int B)
		{
			if(B==0)
			{
				d = A;
				p = 1 ;
				q = 0;
			}
			else
			{
				extendedEuclid(B, A%B);
				int temp = p;
				p = q;
				q = temp - (A/B)*q;
			}
		}

		public static long LCM(long a,long b)
		{
			return (a*b)/GCD(a,b);
		}

		public static int LCM(int a,int b)
		{
			return (a*b)/GCD(a,b);
		}

		public static int binaryExponentiation(int x,int n)
		{
		    int result=1;
		    while(n>0)
		    {
		        if(n % 2 ==1)
		            result=result * x;
		        x=x*x;
		        n=n/2;
		    }
		    return result;
		}

		public static long binaryExponentiation(long x,long n)
		{
		    long result=1;
		    while(n>0)
		    {
		        if(n % 2 ==1)
		            result=result * x;
		        x=x*x;
		        n=n/2;
		    }
		    return result;
		}

		public static int modularExponentiation(int x,int n,int M)
		{
		    int result=1;
		    while(n>0)
		    {
		        if(n % 2 ==1)
		            result=(result * x)%M;
		        x=(x*x)%M;
		        n=n/2;
		    }
		    return result;
		}

		public static long modularExponentiation(long x,long n,long M)
		{
		    long result=1;
		    while(n>0)
		    {
		        if(n % 2 ==1)
		            result=(result * x)%M;
		        x=(x*x)%M;
		        n=n/2;
		    }
		    return result;
		}

		public static long modInverse(int A,int M)
		{
		    return modularExponentiation(A,M-2,M);
		}

		public static long modInverse(long A,long M)
		{
		    return modularExponentiation(A,M-2,M);
		}

		public static boolean isPrime(int n)
		{

		    if (n <= 1)  return false;
		    if (n <= 3)  return true;

		    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;
		}

		 public static long[] shuffle(long[] a, Random gen){
		        for(int i = 0, n = a.length;i < n;i++){
		            int ind = gen.nextInt(n-i)+i;
		            long d = a[i];
		            a[i] = a[ind];
		            a[ind] = d;
		        }
		        return a;
		    }
		static class pair implements Comparable<pair>
		{
			Long x;
			Integer y;
			pair(long a,int m)
			{
				this.x=a;
				this.y=m;
			}

		public int compareTo(pair o) {
				int result = x.compareTo(o.x);
				if(result==0)
					result = y.compareTo(o.y);

				return result;
			}

			public String toString()
			{
				return x+" "+y;
			}

			public boolean equals(Object o)
			{
				if (o instanceof pair)
			    {
					pair p = (pair)o;
					return p.x == x && p.y == y ;
				}
				return false;
			}

			public int hashCode()
			{
				return new Long(x).hashCode()*31 + new Long(y).hashCode();
			}
		}
}

import java.io.*;
import java.util.*;
import java.text.*;
import java.lang.*;
import java.math.BigInteger;
import java.util.regex.*;
public class Myclass {
	public static boolean visited[]=new boolean[300001];
	static ArrayList [] a=new ArrayList[300001];
	public static Vector<Integer>v=new Vector<>();
	public static void dfs(int n)
	{
		visited[n]=true;
		v.add(n);
		for(int i=0;i<a[n].size();i++)
		{
			int temp=(int) a[n].get(i);
			if(!visited[temp])
				dfs(temp);
		}
	}
	public static void main(String[] args)
	{
	    InputReader in = new InputReader(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		long n=in.nextLong();
		long k=in.nextLong();
		long t=in.nextLong();
		long temp=(t%(3*k));
		if(temp<=k)
			pw.println(temp);
		else if(temp>k&& temp<=2*k)
			pw.println(k);
		else
			pw.println(3*k-temp);

		pw.flush();
		pw.close();

	}

		static class InputReader
		{
		private final InputStream stream;
		private final byte[] buf = new byte[8192];
		private int curChar, snumChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream)
		{
			this.stream = stream;
		}
		public int snext()
		{
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars)
			{
				curChar = 0;
				try
				{
					snumChars = stream.read(buf);
				}
				catch (IOException e)
				{
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt()
	    {
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			int sgn = 1;
			if (c == '-')
		    {
				sgn = -1;
				c = snext();
			}
			int res = 0;
			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public long nextLong()
	    {
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = snext();
			}
			long res = 0;
			do
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n)
		{
			int a[] = new int[n];
			for (int i = 0; i < n; i++)
			{
				a[i] = nextInt();
			}
			return a;
		}

		public String readString()
	    {
			int c = snext();
			while (isSpaceChar(c))
			{
				c = snext();
			}
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = snext();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public String nextLine()
		{
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			StringBuilder res = new StringBuilder();
			do
			{
				res.appendCodePoint(c);
				c = snext();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c)
		{
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c)
		{
			return c == '\n' || c == '\r' || c == -1;
		}

		public interface SpaceCharFilter
	    {
			public boolean isSpaceChar(int ch);
		}
	}
		public static long mod = 1000000007;
		public static int d;
		public static int p;
		public static int q;

		public static int[] suffle(int[] a,Random gen)
		{
			int n = a.length;
			for(int i=0;i<n;i++)
			{
				int ind = gen.nextInt(n-i)+i;
				int temp = a[ind];
				a[ind] = a[i];
				a[i] = temp;
			}
			return a;
		}

		public static void swap(int a, int b){
			int temp = a;
			a = b;
			b = temp;
		}

		public static HashSet<Integer> primeFactorization(int n)
		{
			HashSet<Integer> a =new HashSet<Integer>();
			for(int i=2;i*i<=n;i++)
			{
				while(n%i==0)
				{
					a.add(i);
					n/=i;
				}
			}
			if(n!=1)
				a.add(n);
			return a;
		}

		public static void sieve(boolean[] isPrime,int n)
		{
			for(int i=1;i<n;i++)
				isPrime[i] = true;

			isPrime[0] = false;
			isPrime[1] = false;

			for(int i=2;i*i<n;i++)
			{
				if(isPrime[i] == true)
				{
					for(int j=(2*i);j<n;j+=i)
						isPrime[j] = false;
				}
			}
		}

		public static int GCD(int a,int b)
		{
			if(b==0)
				return a;
			else
				return GCD(b,a%b);
		}

		public static long GCD(long a,long b)
		{
			if(b==0)
				return a;
			else
				return GCD(b,a%b);
		}

		public static void extendedEuclid(int A,int B)
		{
			if(B==0)
			{
				d = A;
				p = 1 ;
				q = 0;
			}
			else
			{
				extendedEuclid(B, A%B);
				int temp = p;
				p = q;
				q = temp - (A/B)*q;
			}
		}

		public static long LCM(long a,long b)
		{
			return (a*b)/GCD(a,b);
		}

		public static int LCM(int a,int b)
		{
			return (a*b)/GCD(a,b);
		}

		public static int binaryExponentiation(int x,int n)
		{
		    int result=1;
		    while(n>0)
		    {
		        if(n % 2 ==1)
		            result=result * x;
		        x=x*x;
		        n=n/2;
		    }
		    return result;
		}

		public static long binaryExponentiation(long x,long n)
		{
		    long result=1;
		    while(n>0)
		    {
		        if(n % 2 ==1)
		            result=result * x;
		        x=x*x;
		        n=n/2;
		    }
		    return result;
		}

		public static int modularExponentiation(int x,int n,int M)
		{
		    int result=1;
		    while(n>0)
		    {
		        if(n % 2 ==1)
		            result=(result * x)%M;
		        x=(x*x)%M;
		        n=n/2;
		    }
		    return result;
		}

		public static long modularExponentiation(long x,long n,long M)
		{
		    long result=1;
		    while(n>0)
		    {
		        if(n % 2 ==1)
		            result=(result * x)%M;
		        x=(x*x)%M;
		        n=n/2;
		    }
		    return result;
		}

		public static long modInverse(int A,int M)
		{
		    return modularExponentiation(A,M-2,M);
		}

		public static long modInverse(long A,long M)
		{
		    return modularExponentiation(A,M-2,M);
		}

		public static boolean isPrime(int n)
		{

		    if (n <= 1)  return false;
		    if (n <= 3)  return true;

		    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;
		}

		 public static long[] shuffle(long[] a, Random gen){
		        for(int i = 0, n = a.length;i < n;i++){
		            int ind = gen.nextInt(n-i)+i;
		            long d = a[i];
		            a[i] = a[ind];
		            a[ind] = d;
		        }
		        return a;
		    }
		static class pair implements Comparable<pair>
		{
			Long x;
			Integer y;
			pair(long a,int m)
			{
				this.x=a;
				this.y=m;
			}

		public int compareTo(pair o) {
				int result = x.compareTo(o.x);
				if(result==0)
					result = y.compareTo(o.y);

				return result;
			}

			public String toString()
			{
				return x+" "+y;
			}

			public boolean equals(Object o)
			{
				if (o instanceof pair)
			    {
					pair p = (pair)o;
					return p.x == x && p.y == y ;
				}
				return false;
			}

			public int hashCode()
			{
				return new Long(x).hashCode()*31 + new Long(y).hashCode();
			}
		}
}

import java.util.*;
public class ProblemA {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long k = sc.nextLong();
		long t = sc.nextLong();

		if(t<=k){
			System.out.println(t);
		}
		else{
			if(t<=n){
				System.out.println(n-k);
			}
			else{
				System.out.println(n+k-t);
			}
		}

	}

}

import java.util.*;
public class ProblemA {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long k = sc.nextLong();
		long t = sc.nextLong();

		if(t<=k){
			System.out.println(t);
		}
		else{
			if(t<=n){
				System.out.println(n-k);
			}
			else{
				System.out.println(2*n-t-k);
			}
		}

	}

}

import java.util.Scanner;
public class MexicanWave {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int spectators = sc.nextInt();
		int position = sc.nextInt();
		int time = sc.nextInt();

		if (time <= position) {

			System.out.println(position);

		} else if (time > position && time <= spectators) {

			System.out.println(position);

		} else {

			System.out.println(spectators + position - time);

		}
	}

}

import java.util.Scanner;
public class MexicanWave {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int spectators = sc.nextInt();
		int position = sc.nextInt();
		int time = sc.nextInt();

		if (time <= position) {
			System.out.println(time);
		} else if (time > position && time <= spectators) {

		} else {
			System.out.println(position + time - spectators);
		}
	}

}

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws Throwable
	{
		Scanner sc = new Scanner((System.in));
		int n = sc.nextInt();
		int k = sc.nextInt();
		int t = sc.nextInt();
		if(t<=k)
		{
			System.out.println(t);
			return;
		}
		if(t>k && t<=n)
		{
			System.out.println(k);
			return;
		}
		System.out.println(k-t-n);
	}

	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}
		public Scanner(String s) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(s));
		}
		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {return Integer.parseInt(next());}

		public String nextLine() throws IOException {return br.readLine();}

		public long nextLong() throws IOException {return Long.parseLong(next());}

		public boolean ready() throws IOException {return br.ready();}
	}
}

import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class WetShark
{
    static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }
 static int max(int a[],int n) {
	 int max=a[0];
	 int ind=0;
	 for(int i=1;i<n;i++) {
		 if(a[i]>=max) {
			 max=a[i];
			 ind=i;
		 }
	 }
	 return ind;
 }
 static int min(int a[],int n) {
	 int min=a[0];
	 int ind=0;
	 for(int i=1;i<n;i++) {
		 if(a[i]<min) {
			 min=a[i];
			 ind=i;
		 }
	 }
	 return ind;
 }
 static boolean fun(int i) {
	 for(int j=3;j<=20;j++) {
		 if(i%j!=0) {
			 return false;
		 }
	 }
	 return true;
 }
 static int bin(int arr[], int l, int r, int x)
 {
     if (r>=l)
     {
         int mid = l + (r - l)/2;

         if (arr[mid] == x)
            return mid;

         if (arr[mid] > x)
            return bin(arr, l, mid-1, x);
         return bin(arr, mid+1, r, x);
     }

     return -1;
 }
    public static void main(String[] args) throws IOException
    {
        Reader s=new Reader();
        int n=s.nextInt();
       int k=s.nextInt();
       int t=s.nextInt();
       int a=Math.min(k,n+k-t);
       System.out.println(Math.min(a, n));

}
}

import java.util.Scanner;
public class main{
	public static void main(String[]args){
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int k = input.nextInt();
		int t = input.nextInt();
		int res = 0;
		if(n>=t && k>t){
			res = t;
		}
		else if(n>t && t>=k){
			res = k;
		}
		else if(n<t){
			res = (t-n)-k;
		}
		if(res<-1){
			res *= -1;
		}
		System.out.println(res);
	}
}

// 1508123779797

import java.util.Scanner;
public class main{
	public static void main(String[]args){
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int k = input.nextInt();
		int t = input.nextInt();
		int res = 0;
		if(n>=t && t>= k){
			res = k;
		}
		else if(n>=t && t<k){
			res = t;
		}
		else{
			res = (t-n)-k;
		}
		if(res<-1){
			res *= -1;
		}
		System.out.println(res);
	}
}

// 1508116041032

import java.util.*;

public class Solution {

  private static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    int n = sc.nextInt(), k = sc.nextInt(), t = sc.nextInt();
    if (t <= k) {
      System.out.println(t);
    } else if (t >= n) {
      System.out.println(t + k - n);
    } else {
      System.out.println(k);
    }
  }

}

import java.util.*;
public class JavaApplication7 {
 public static void main(String[] args) {
  Scanner obj = new Scanner(System.in);
  int [] arr = new int [3];
  for(int i=0 ; i<3; i ++)  arr[i]=obj.nextInt();
  if(arr[2]<=arr[1])
      System.out.println(arr[2]);
  else if (arr[2]<=(arr[1])*2)
      System.out.println(arr[1]);
  else{
      int n=arr[2]-arr[0];
      System.out.println(arr[1]-n);
  }
 }}

import java.util.*;
public class JavaApplication7 {
 public static void main(String[] args) {
  Scanner obj = new Scanner(System.in);
  int [] arr = new int [3];
  for(int i=0 ; i<3; i ++)  arr[i]=obj.nextInt();
  if(arr[2]<=arr[1])
      System.out.println(arr[2]);
  else if (arr[2]<=(arr[1])*2)
      System.out.println(arr[1]);
  else
      System.out.println((arr[2]/arr[1])+1);

 }}

import java.util.Scanner;

public class Main {
    public static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        long n = scanner.nextLong();
        long k = scanner.nextLong();
        long t = scanner.nextLong();

        if (t>k && t<n){
            System.out.println(k);
        } else if (t < k){
            System.out.println(t);
        } else if (t > n){
            System.out.println(k-t+n);
        }

    }
}

        import java.util.Scanner;

public class MexicanWave
{
        public static void main ( String [] args )
        {
                Scanner Input = new Scanner( System.in ) ;
                int Total = Input.nextInt ( ) ;
                int Wave = Input.nextInt ( ) ;
                int Time = Input.nextInt ( ) ;
                if ( Time < Wave )
                {
                        System.out.println ( Time ) ;
                }
                else if ( Total > Time && Time > Wave )
                {
                        System.out.println ( Wave ) ;
                }
                else
                {
                        System.out.println ( ( Wave + Total ) % Time ) ;
                }
        }
}

import java.util.Scanner;
public class Arpa1
{
    int n,k,t,count;
    void input()
    {
        Scanner sc=new Scanner(System.in);
        n=sc.nextInt();
        k=sc.nextInt();
        t=sc.nextInt();
    }
    void calc()
    {
        for(int i=1;i<=t;i++)
        {
            if(i<k)
             count++;
             else
            if(i>k && i<=n)
             {
             }
             else
             if(i>n)
             count--;
        }
    }
    public static void main(String[] args)
    {
        Arpa1 obj=new Arpa1();
        obj.input();
        obj.calc();
        System.out.println(obj.count);
    }
}

import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        long n = s.nextLong();
        long k = s.nextLong();
        long t = s.nextLong();
        if(t<n&&t<k){
            System.out.println(t);
        }else if(t<n && t>k){
            System.out.println(k);
        }else{
            System.out.println((n+k)-t);
        }
    }
    }

import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigDecimal;

public class R432B {
    public static void main (String[] args) throws java.lang.Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter w = new PrintWriter(System.out);
        long n = in.nextLong(), k = in.nextLong(), t = in.nextLong();
        if (t < k)
            w.println(t);
        else if (t >= k && t <= n)
            w.println(k);
        else
            w.println(k - (t % k));

        w.close();
    }

}

import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigDecimal;

public class R432B {
    public static void main (String[] args) throws java.lang.Exception {
        Scanner in = new Scanner(System.in);
        PrintWriter w = new PrintWriter(System.out);
        long n = in.nextLong(), k = in.nextLong(), t = in.nextLong();
        if (t <= k)
            w.println(Math.min(t, n));
        else if (t > k && t <= n)
            w.println(k);
        else
            w.println(k - (t % k));

        w.close();
    }

}

import java.util.*;
import java.lang.*;

public class p
{
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);

		int n,k,t;

		n = in.nextInt();
		k = in.nextInt();
		t = in.nextInt();

		if(t<=k)System.out.println(t);

		if(k<t && t<=n) System.out.println(k);

		else{
		System.out.println(k-(t-n));
		}

	}
}

import java.util.*;
import java.io.*;
import java.math.*;
public class loser
{
    static class InputReader {
        public BufferedReader br;
        public StringTokenizer token;
        public InputReader(InputStream stream)
        {
            br=new BufferedReader(new InputStreamReader(stream),32768);
            token=null;
        }

        public String next()
        {
            while(token==null || !token.hasMoreTokens())
            {
                try
                {
                    token=new StringTokenizer(br.readLine());
                }
                catch(IOException e)
                {
                    throw new RuntimeException(e);
                }
            }
            return token.nextToken();
        }

        public int nextInt()
        {
            return Integer.parseInt(next());
        }

        public long nextLong()
        {
            return Long.parseLong(next());
        }
    }
    static class card{
        int l;
        int r;
        public card(int ch,int i)
        {
            this.l=ch;
            this.r=i;
        }
    }
    static class sort implements Comparator<card>
    {
        public int compare(card o1,card o2)
        {
            if(o1.l!=o2.l)
                return (int)(o1.l-o2.l);
            else
                return (int)(o1.r-o2.r);
        }
    }
    static void shuffle(long a[])
    {
        List<Long> l=new ArrayList<>();
        for(int i=0;i<a.length;i++)
            l.add(a[i]);
        Collections.shuffle(l);
        for(int i=0;i<a.length;i++)
            a[i]=l.get(i);
    }

    /*static long gcd(long a,long b)
    {
    if(b==0)
    return a;
    else
    return gcd(b,a%b);
    }
    static int ans1=Integer.MAX_VALUE,ans2=Integer.MAX_VALUE,ans3=Integer.MAX_VALUE,ans4=Integer.MAX_VALUE;
    static boolean v[]=new boolean[101];
    static void dfs(Integer so,Set<Integer> s[]){
    if(!v[so.intValue()])
    {
    v[so]=true;
    for(Integer h:s[so.intValue()])
    {
    if(!v[h.intValue()])
    dfs(h,s);
    }
    }
    }
    static class Print{
    public PrintWriter out;
    Print(OutputStream o)
    {
    out=new PrintWriter(o);
    }
    }
    static int CeilIndex(int A[], int l, int r, int key)
    {
    while (r - l > 1) {
    int m = l + (r - l) / 2;
    if (A[m] >= key)
    r = m;
    else
    l = m;
    }

    return r;
    }

    static int LongestIncreasingSubsequenceLength(int A[], int size)
    {
    // Add boundary case, when array size is one
    int[] tailTable = new int[size];
    int len; // always points empty slot
    tailTable[0] = A[0];
    len = 1;
    for (int i = 1; i < size; i++) {
    if (A[i] < tailTable[0])
    // new smallest value
    tailTable[0] = A[i];

    else if (A[i] > tailTable[len - 1])
    // A[i] wants to extend largest subsequence
    tailTable[len++] = A[i];

    else
    // A[i] wants to be current end candidate of an existing
    // subsequence. It will replace ceil value in tailTable
    tailTable[CeilIndex(tailTable, -1, len - 1, A[i])] = A[i];
    }
    return len;
    }*/
    /*static int binary(int n)
    {
    int s=1;
    while(n>0)
    {
    s=s<<1;
    n--;
    }
    return s-1;
    }
    static StringBuilder bin(int i,int n)
    {
    StringBuilder s=new StringBuilder();
    while(i>0)
    {
    s.append(i%2);
    i=i/2;
    }
    while(s.length()!=n)
    {
    s.append(0);
    }
    return s.reverse();
    }*/
    public static void main(String[] args)
    {
        InputReader sc=new InputReader(System.in);
        long n=sc.nextLong();
        long k=sc.nextLong();
        long t=sc.nextLong();
        long ans=0;
        if(t<k)
        ans=t;
        else if(t>=k && t<=n)
        ans=k;
        else
        ans=n-(k+(t%k));
        System.out.println(ans);
    }
}

import java.io.*;
public class sample{
	public static void main(String[] args) throws IOException
	{
		BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
		int n,k,t;
		String str[]=input.readLine().split(" ");
		n=Integer.parseInt(str[0]);
		k=Integer.parseInt(str[1]);
		t=Integer.parseInt(str[2]);
		int rem=t%(3*k-1);
		//System.out.println(rem);
		if(rem==0)System.out.println(0);
		else if(0<rem && rem<=k)System.out.println(rem);
		else if(rem>k && rem<=2*k-1)System.out.println(k);
		else System.out.println(k-rem%(2*k));
	}
}

import java.util.*;

public class Problem3 {
    public static void main(String args[]) {
        Scanner kbd = new Scanner(System.in);

        int n = kbd.nextInt();

        int k = kbd.nextInt();

        int t = kbd.nextInt();

        if (t <= k && t <= n){
            System.out.println(t);

        }else if (t <= n){
            System.out.println(k);

        }else{
            System.out.print(k+t+n);
        }
    }
}

import java.util.*;
public class Wave
{
    public static void main(String args[])
    throws Exception
    {
        Scanner scan=new Scanner(System.in);
        long n=scan.nextLong();
        long k=scan.nextLong();
        long t=scan.nextLong();
        long stand=0;
            if(t<=k)
            {
            stand=t;
        }
            else if(t>=k && t<=n)
            {
            stand=k;
        }
            else
            {
            stand=(t-k);
        }
        System.out.print(stand);
    }
}

import java.util.*;

/**
 *
 * @author asus
 */
public class ArpaAndAResearchInMexiacanWave {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int k = input.nextInt();
        int t = input.nextInt();
        int standing = 0;

        if(t < 5) {
        	standing = t;
        } else if(t > n) {
        	standing = 5 - (t - n);
        } else {
        	standing = 5;
        }

        System.out.println(standing);

    }

}

import java.util.*;

public class ApraAndASearchInAMexicanWave {

    public static void main(String[] args) {
        Scanner kbd = new Scanner(System.in);
        int k = kbd.nextInt();
        int n = kbd.nextInt();
        int t = kbd.nextInt();

        if (t <= k) {
            System.out.println(t);
        } else {
            if (t > k && t <= n) {
                System.out.println(k);
            } else {
                System.out.println(k-(t-n));
            }
        }
    }
}

/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();
		int t = in.nextInt();

		System.out.println(Math.min(k, n + k - t));
	}
}

import java.util.Scanner;

/**
 * Created by phuoc on 9/1/17.
 */
public class A_432 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        int t = in.nextInt();
        if (t <= k) {
            System.out.println(t);
        } else if (t >= n) {
            System.out.println(2 * n - (t + k));
        } else System.out.println(k);
    }
}

import java.util.*;

public class Arpa {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n, k, t;
        String input = scan.nextLine();
        String inputLine[] = input.split(" ");
        n = Integer.parseInt(inputLine[0]);
        k = Integer.parseInt(inputLine[1]);
        t = Integer.parseInt(inputLine[2]);

        if(t <= k && t <= n) {
            System.out.print(t);
        } else if(t <= n) {
            System.out.print(k);
        } else {
            if(0 < k - (t - n)) {
                System.out.print(0);
            } else {
                System.out.print(k - (t - n));
            }
        }
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int t = in.nextInt();
            if (t >= k && t <= n) {
                out.println(k);
            } else {
                if (t < k) {
                    out.println(t);
                } else {
                    out.println(t - n + 1);
                }
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

import java.util.Scanner;

public class Arpa {

	public static void main(String[] args)
        {
		Scanner input=new  Scanner (System.in);
		int n=input.nextInt();
		int k=input.nextInt();
		int t=input.nextInt();
                if(t<=k)
                    System.out.println(t);
                if(t>k && t<=n)
                    System.out.println(k);
                else
                    System.out.println(n+k-t);
        }

}

import java.util.Scanner;
public class main{
	public static void main(String[]args){
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int k = input.nextInt();
		int t = input.nextInt();
		int res = 0;
		if(n>t){
			res = k;
		}
		else{
			res = (t-n)-k;
		}
		if(res<-1){
			res *= -1;
		}
		System.out.println(res);
	}
}

// 1508115569196

import java.io.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), k = in.nextInt(), t = in.nextInt();
        if (t <= k) System.out.println(t);
        else System.out.println(k);

    }
}

import java.io.*;
        import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), k = in.nextInt(), t = in.nextInt();
        if (t <= k) System.out.println(t);
        else if (t >= n) System.out.println(t-n+1);
        else System.out.println(k);

    }
}

import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
			solve();
	}
	public static void solve() {
		int n = sc.nextInt();
		int k = sc.nextInt();
            int t = sc.nextInt();

            if(t<=n)
		System.out.println(Math.min(t, k));
		else
		System.out.println(k+t-n);
	}
}

import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
			solve();
	}
	public static void solve() {
		int n = sc.nextInt();
		int k = sc.nextInt();
            int t = sc.nextInt();

            if(t<=n)
		System.out.println(Math.min(t, k));
		else
		System.out.println(n-k);
	}
}

import java.util.Scanner;

public class Solution {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		long n = s.nextLong();
		long k = s.nextLong();
		long t = s.nextLong();
		long a = 0;
		long b = 0;

		for(int i = 0; i < n ; i++) {
			a = k+1;
			b = i;
		}
		System.out.println(b-a);
	}
}

import java.util.Scanner;

public class Solution {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		long n = s.nextLong();
		long k = s.nextLong();
		long t = s.nextLong();
		long a = 0;

		for(int i = 0; i < n ; i++) {
			a = k+1;
			a -= 1;
		}

		System.out.println(a);
	}
}

import java.util.Scanner;

public class Solution {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		long n = s.nextLong();
		long k = s.nextLong();
		long t = s.nextLong();

		System.out.println(5);
	}
}

import java.util.*;

/**
 *
 * @author pranav//javaapplication1.JavaApplication1
 */
public class JavaApplication1 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)
    { int n,k,t;
     System.out.println("enter the input");
     Scanner in=new Scanner(System.in);
     n=in.nextInt();
     k=in.nextInt();
     t=in.nextInt();
    Spectators s=new Spectators();
    s.cal(n,k,t);
    }}

 class Spectators{
    public void cal(int n1,int k1,int t1)
    {

     if(t1<k1)
     {System.out.println(t1);}
     else if(t1>=k1&&t1<=n1)
     {System.out.println(k1);}
     else if(t1>n1)
     {System.out.println(k1-(t1-n1));}

}}

import java.util.*;
import java.io.*;

public final class Main {

    public static void main(String[] args) throws Exception {
        PrintWriter pw = new PrintWriter(System.out);
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());

        long n = Long.parseLong(st.nextToken());
        long k = Long.parseLong(st.nextToken());
        long t = Long.parseLong(st.nextToken());

        if(t <= k){
            System.out.println(t);
            return;
        }

        if(t <= n){
            System.out.println(n-k);
            return;
        }

        pw.println(Math.max(0,(n-k)-(t-n)));
        pw.close();
    }
}

import java.util.*;
import java.io.*;

public final class Main {

    public static void main(String[] args) throws Exception {
        PrintWriter pw = new PrintWriter(System.out);
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());

        long n = Long.parseLong(st.nextToken());
        long k = Long.parseLong(st.nextToken());
        long t = Long.parseLong(st.nextToken());

        if(t <= k){
            System.out.println(t);
            return;
        }

        if(t <= n){
            System.out.println(t - (t-k));
            return;
        }

        pw.println(Math.max(0,(n-k)-(t-n)));
        pw.close();
    }
}

import java.io.*;
import java.util.*;

public class MexicanWave
{
	public static void main(String[] args) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());

	      int n, k, t;
	      n = Integer.parseInt(st.nextToken());
	      k = Integer.parseInt(st.nextToken());
	      t = Integer.parseInt(st.nextToken());
	      if(t<k) System.out.println(t);
	      else if(t<=2*k) System.out.println(k);
	      else System.out.println(k-(t%k));
	}
}

/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Wave
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc=new Scanner(System.in);
		int n,k,t;
		n=sc.nextInt();
		k=sc.nextInt();
		t=sc.nextInt();
		int ans=0;
		if(t<k)
			ans=t;
		else if(t>=k)
			ans=k-(t-n);
		System.out.println(ans);
	}
}

import java.util.Scanner;
public class main{
	public static void main(String[]args){
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int k = input.nextInt();
		int t = input.nextInt();
		int res = 0;
		if(n>=t){
			res = k;
		}
		else{
			res = (t-n)-k;
		}
		System.out.println(res);
	}
}

// 1508115690161

import java.util.Scanner;
public class main{
	public static void main(String[]args){
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int k = input.nextInt();
		int t = input.nextInt();
		int res = 0;
		if(n>=t && k>t){
			res = t;
		}
		else if(n>t && t>=k){
			res = k;
		}
		else if(n<t){
			res = (t-n)-k;
		}
		if(res<-1){
			res *= -1;
		}
		System.out.println(res);
	}
}
// 1508123921906

import java.util.Scanner;
public class main{
	public static void main(String[]args){
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int k = input.nextInt();
		int t = input.nextInt();
		int res = 0;
		if(t>=k){
			res = k;
		}
		else if(t<k){
			res = t;
		}
		else{
			res = (t-n)-k;
		}
		if(res<-1){
			res *= -1;
		}
		System.out.println(res);
	}
}

// 1508117843878

import java.util.Scanner;

public class Codeforces851A {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n=scan.nextInt();
		int k=scan.nextInt();
		int t=scan.nextInt();

		if(t<=n && t > k) {
			System.out.println(k);
		} else if (t<=k) {
			System.out.println(t);
		} else {
			System.out.println(t-n+k);
		}
	}
}

import java.io.*;
import java.util.*;

public class A {

	public static void main(String[] args) {
		FastScannerA sc = new FastScannerA(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();
		int T = sc.nextInt();

		if(T <= K){
			System.out.println(T);
		}
		else if(T <= N){
			System.out.println(K);
		}
		else{
			System.out.println(T - N);
		}

	}
}

class FastScannerA{
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;

    public FastScannerA(InputStream stream)
    {
        this.stream = stream;
    }

    public int read()
    {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars)
        {
            curChar = 0;
            try
            {
                numChars = stream.read(buf);
            } catch (IOException e)
            {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int nextInt()
    {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-')
        {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do
        {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public String next()
    {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do
        {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    public String nextLine()
    {
        int c = read();
        StringBuilder res = new StringBuilder();
        do
        {
            res.appendCodePoint(c);
            c = read();
        } while (!isLineEndChar(c));
        return res.toString();
    }

    public double nextDouble() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        double res = 0;
        while (!isSpaceChar(c) && c != '.') {
            if (c == 'e' || c == 'E')
                return res * Math.pow(10, nextInt());
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        }
        if (c == '.') {
            c = read();
            double m = 1;
            while (!isSpaceChar(c)) {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                m /= 10;
                res += (c - '0') * m;
                c = read();
            }
        }
        return res * sgn;
    }

    public long nextLong() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public boolean isSpaceChar(int c)
    {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public boolean isLineEndChar(int c)
    {
        if (filter != null)
            return filter.isSpaceChar(c);
        return c == '\n' || c == '\r' || c == -1;
    }

    public interface SpaceCharFilter
    {
        public boolean isSpaceChar(int ch);
    }
}