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. 

import java.io.BufferedOutputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Scanner;

/**
 * Created by imahmoud on 5/13/17.
 */
public class A {
    static class Writer {
        private OutputStream out;
        public Writer(){
            out = new BufferedOutputStream(System.out);
        }

        public void println() throws IOException {
            out.write('\n');
        }
        public void println(String str) throws IOException {
            this.print(str);
            out.write('\n');
        }
        public void println(char v) throws IOException {
            this.print(v);
            out.write('\n');
        }
        public void println(short v) throws IOException {
            this.print(v);
            out.write('\n');
        }
        public void println(int v) throws IOException {
            this.print(v);
            out.write('\n');
        }
        public void println(long v) throws IOException {
            this.print(v);
            out.write('\n');
        }
        public void println(double v) throws IOException {
            this.print(v);
            out.write('\n');
        }
        public void println(float v) throws IOException {
            this.print(v);
            out.write('\n');
        }

        public void print(String str) throws IOException {
            out.write(str.getBytes());
        }
        public void print(char v) throws IOException {
            out.write(String.valueOf(v).getBytes());
        }
        public void print(short v) throws IOException {
            out.write(String.valueOf(v).getBytes());
        }
        public void print(int v) throws IOException {
            out.write(String.valueOf(v).getBytes());
        }
        public void print(long v) throws IOException {
            out.write(String.valueOf(v).getBytes());
        }
        public void print(double v) throws IOException {
            out.write(String.valueOf(v).getBytes());
        }
        public void print(float v) throws IOException {
            out.write(String.valueOf(v).getBytes());
        }

        public void flush() throws IOException {
            out.flush();
            out.close();
        }
    }
    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 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();
        }
    }

    public void solve()  throws IOException{
        Scanner in =  new Scanner(System.in);
        Writer out = new Writer();

        long N = in.nextLong();
        long K = in.nextLong();
        long T = in.nextLong();

        if(T <K){
            out.println(T);
        }else if(T > N ){
            long s = T - N;
            if(s <= K)
                out.print(K - s);
            else
                out.print(0);
        }else{
            out.print(K);
        }
        out.flush();

    }
    public static void main(String[] args) {
        try {
            new A().solve();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
