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 ≤ 10^9, 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  ---------- $\Rightarrow$ number of standing spectators = 0.  At t = 1  ^--------- $\Rightarrow$ number of standing spectators = 1.  At t = 2  ^^-------- $\Rightarrow$ number of standing spectators = 2.  At t = 3  ^^^------- $\Rightarrow$ number of standing spectators = 3.  At t = 4  ^^^^------ $\Rightarrow$ number of standing spectators = 4.  At t = 5  ^^^^^----- $\Rightarrow$ number of standing spectators = 5.  At t = 6  -^^^^^---- $\Rightarrow$ number of standing spectators = 5.  At t = 7  --^^^^^--- $\Rightarrow$ number of standing spectators = 5.  At t = 8  ---^^^^^-- $\Rightarrow$ number of standing spectators = 5.  At t = 9  ----^^^^^- $\Rightarrow$ number of standing spectators = 5.  At t = 10 -----^^^^^ $\Rightarrow$ number of standing spectators = 5.  At t = 11 ------^^^^ $\Rightarrow$ number of standing spectators = 4.  At t = 12 -------^^^ $\Rightarrow$ number of standing spectators = 3.  At t = 13 --------^^ $\Rightarrow$ number of standing spectators = 2.  At t = 14 ---------^ $\Rightarrow$ number of standing spectators = 1.  At t = 15 ---------- $\Rightarrow$ number of standing spectators = 0.

Difficulty: interview

Starter code:

Solutions:
def read_ints():
	return [int(i) for i in input().split()]

n, k, t = read_ints()
if t <= k:
	print(t)
elif t > n:
	print(k + n - t)
else:
	print(k)

def list_input():
    return list(map(int,input().split()))
def map_input():
    return map(int,input().split())
def map_string():
    return input().split()
    
n,k,t = map_input()
if t <= k:
  print(t)
elif t <= n:
  print(k)
else:
  print(k+n-t)

n,k,t = map(int,input().split())
if(t <= k):
	print(t)
elif(t >= n+1):
	print(n+k-t)
else:
	print(k)

n, k, t = list(map(int, input().split()))
if t <= k:
	print(t)
elif k < t <= n:
	print(k)
else:
	print(k - t + n)

n, k, t = map(int, input().split())
if t <= n:
    print(min(t, k))
else:
    print(k - t + n)

n,k,t = [int(i) for i in input().split()]
if t < k:
    print(t)
elif t > n:
    print(k-t+n)
else:
    print(k)

n, k, t = map(int, input().split())
if t < k:
    print(t)
else:
    print(k - max(t - n, 0))

n,k,t = map(int, input().split())
if t >= k and t <= n:
    print(k)
elif t < k:
    print(t)
else:
    print(k - (t - n))

from sys import stdin, stdout

n,k,t = list(map(int,stdin.readline().rstrip().split()))

print(max([min([n,t])-max([0,t-k]),0]))


import sys

n, k, t = [int(d) for d in sys.stdin.readline().split()]
if t < k:
    print(t)
elif t > n:
    print(n+k-t)
else:
    print(k)


n, k, t = [int(i) for i in input().split()]
if t < k:
    print(t)
    return
if n + 1 <= t:
    print(n + k - t)
    return
print(k)

n, k, t = map(int, input().split())

if t <= k:
	print(t)
elif t >= n:
	print(n+k-t)
else:
	print(k)

N, K, T = list(map(int, input().split()))

if T < K:
    print(T)
elif N < T:
    print(N+K-T)
else:
    print(K)


n,k,t=list(map(int,input().split()))
if (t<=k):
    print(t)
else:
    if (t <=n):
        print(k)
    else:
        print(n+k-t)


n,k,t=list(map(int,input().split()))
if t>=k and t<=n:
    print(k)
else:
    if t<k:
        print(t)
    else:
        print(k-(t-n))


n, k, t = list(map(int, input().split()))

if t < k:
    print(t)
elif t >= k and t <= n:
    print(k)
else:
    print(k - t + n)


n, k, t = map(int, input().split())
if t <= k:
    print(t)
elif t <= n:
    print(k)
else:
    print(k - (t - n))

n,k,t = map(int,input().split())
if t <= k:
  res = t
elif t <= n:
  res = k
else:
  res = (n+k) - t
print(res)

n,k,t=map(int, input().split())
if(t<k):
  print(t)
elif(t<=n and t>=k):
  print(k)
else:
  print(k-(t-n))

n, k, t = list(map(int, input().split(' ')))

def main():
    if t < k:
        return t
    elif k <= t <= n:
        return k
    else:
        return n + k - t

print(main())


n, k, t = map(int, input().split())
if t <= k :
    print(t)
elif t > n:
    print(k - t + n)
else:
    print(k)

n,k,t = list(map(int, input().split()))
if t < k:
  print(t)
elif t > n:
  print(max(0, k-t+n))
else:
  print(k)



n, k, t = map(int, input().split())

if t < k:
    print(t)
elif t > n:
    print(max(0, k - (t - n)))
else:
    print(k)

n, k, t = list(map(int, input().split()))
if t<=k:
    print(t)
elif t<=n:
    print(k)
else:
    print(k - (t - n))


n,t,k = map(int,input().split())

if(t>k):
    print(k)
elif(k>n):
    print(t-(k-n))
else:
    print(t)