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.

Input

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

Output

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

Examples

Input

10 5 3


Output

3


Input

10 5 7


Output

5


Input

10 5 12


Output

3

Note

In the following a sitting spectator is represented as -, a standing spectator is represented as ^.

  * At t = 0  ---------- <image> number of standing spectators = 0. 
  * At t = 1  ^--------- <image> number of standing spectators = 1. 
  * At t = 2  ^^-------- <image> number of standing spectators = 2. 
  * At t = 3  ^^^------- <image> number of standing spectators = 3. 
  * At t = 4  ^^^^------ <image> number of standing spectators = 4. 
  * At t = 5  ^^^^^----- <image> number of standing spectators = 5. 
  * At t = 6  -^^^^^---- <image> number of standing spectators = 5. 
  * At t = 7  --^^^^^--- <image> number of standing spectators = 5. 
  * At t = 8  ---^^^^^-- <image> number of standing spectators = 5. 
  * At t = 9  ----^^^^^- <image> number of standing spectators = 5. 
  * At t = 10 -----^^^^^ <image> number of standing spectators = 5. 
  * At t = 11 ------^^^^ <image> number of standing spectators = 4. 
  * At t = 12 -------^^^ <image> number of standing spectators = 3. 
  * At t = 13 --------^^ <image> number of standing spectators = 2. 
  * At t = 14 ---------^ <image> number of standing spectators = 1. 
  * At t = 15 ---------- <image> number of standing spectators = 0. 
//Number theory -1
//DSU -1,
//Div 2C @unsolved-44,45,47,50,53,54,55,
//graph -1,2,3    @unsolved-540C,4D,295B,526B,500B,682C,506D,103B,329B,161D;
//complete search --NA;
//binary search -1,2,3 @unsolved-                      
//DP - 1,2;@unsolved-289B,446A,467C,158D,676C,166E,553A,118D,611C,518D,602B;
//combinatorics-
//Two pointer-1,2,3-@unsolved-577B,493C,229A,161A,237C,519D,446A;
//Bit masking-1,2,3-@unsolved-

import java.util.*;
import java.io.*;
public class CF851A
{    //*****************************************    VARIABLE DECLERATION SECTION   ********************************************************************;
         //Integer ArrayList Math TreeMap TreeSet
         // System.out.println

    //*****************************************    VARIABLE DECLERATION ENDS   ********************************************************************;

    //************************************************   MAIN FUNCTION  *************************************************************************; 
    public static void main(String[] args) 
    {   
         FastReader scan=new FastReader();
        
         int n=scan.nextInt(),k=scan.nextInt(),t=scan.nextInt();
         if(t<=k)System.out.println(t);
         else if(t<=n)System.out.println(k);
         else System.out.println(k+n-t);

     

    }
    //***********************************************  MAIN FUNCTION ENDS   *********************************************************************;

    //**********************************************   AUXILIARY FUNCTIONS  **********************************************************************;
    /*static void func()
    {

    }*/
    //**********************************************   AUXILIARY FUNCTIONS  ENDS  **********************************************************************;

    //**********************************************   INPUT FUNCTIONS     ******************************************************************************;
       static class FastReader
    {   BufferedReader br;   StringTokenizer st;
        public FastReader()
        {  br = new BufferedReader(new  InputStreamReader(System.in)); }
        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()); }
        double nextDouble()
        {  return Double.parseDouble(next()); }
        String nextLine()
        { String str = "";
            try
            {     str = br.readLine(); }
            catch (IOException e)
            {     e.printStackTrace(); }
            return str;
        }
    }
    //**********************************************   INPUT FUNCTIONS     ******************************************************************************;
}