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: EASY
Tags: Mathematics

Implementation

Starter code:

Solutions:
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) = [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) = [int(x) for x in input().split()]
if t < k:
	print(t)
elif t > n:
	print(n + k - t)
else:
	print(k)


print((lambda a: min(a[1], a[2]) if a[2] <= a[0] else a[1] - a[2] + a[0])(list(map(int, input().split()))))


import math
import re

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

def ri():
	return int(input())

def rfa():
	return [float(i) for i in input().split()]
(n, k, t) = ria()
t %= k + n
if t <= k:
	print(t)
elif t <= n:
	print(k)
else:
	print(k + n - t)


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


(n, k, t) = map(int, input().split(' '))
std = 0
if t <= k:
	std += t
if t > k:
	std += k
	if t > n:
		std -= t - n
print(std)


l1 = input().split()
n = int(l1[0])
k = int(l1[1])
t = int(l1[2])
if t <= k:
	print(t)
	exit()
if t > k and t <= n:
	print(k)
	exit()
if t > n:
	print(k - (t - n))
	exit()


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


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


(a, b, c) = map(int, input().split())
if c <= b:
	print(c)
elif c > b and c < a:
	print(b)
elif c >= a:
	print(b + a - c)


def main():
	(N, K, T) = map(int, input().split())
	ans = min(K, T, N, K - (T - N))
	print(ans)
main()


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


(a, b, c) = list(map(int, input().split()))
if c <= b:
	print(c)
elif c <= a:
	print(b)
else:
	print(a - c + b)


import sys

def main():
	pass

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def lts(l):
	s = ''.join(map(str, l))
	return s

def stl(s):
	l = list(s)
	return l

def sq(a, target, arr=[]):
	s = sum(arr)
	if s == target:
		return arr
	if s >= target:
		return
	for i in range(len(a)):
		n = a[i]
		remaining = a[i + 1:]
		ans = sq(remaining, target, arr + [n])
		if ans:
			return ans

def SieveOfEratosthenes(n):
	cnt = 0
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n + 1):
		if prime[p]:
			cnt += 1
	return cnt

def nCr(n, r):
	f = math.factorial
	return f(n) // f(r) // f(n - r)
mod = int(1000000000.0) + 7

def ssinp():
	return sys.stdin.readline().strip()

def iinp():
	return int(input())

def nninp():
	return map(int, sys.stdin.readline().strip().split())

def llinp():
	return list(map(int, sys.stdin.readline().strip().split()))

def p(xyz):
	print(xyz)

def p2(a, b):
	print(a, b)
import math
(n, k, t) = nninp()
if t <= k:
	p(t)
elif t >= n:
	p(k - (t - n))
else:
	p(k)


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


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


(n, k, l) = map(int, input().split())
print(min(l, k, n + k - l))


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


(a, b, c) = map(int, input().split())
if c <= b:
	print(c, end='')
elif c <= a:
	print(b, end='')
else:
	print(a + b - c, end='')


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

def f():
	if t <= k:
		return t
	elif t > k and t <= n:
		return k
	elif t > n:
		return k - (t - n)
print(f())


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


(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())


import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def LS():
	return sys.stdin.readline().split()

def S():
	return input()

def main():
	(n, k, t) = LI()
	if t <= k:
		return t
	if n < t:
		if n + k < t:
			return 0
		else:
			return n + k - t
	return k
print(main())


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


def solution():
	(n, k, t) = map(int, input().split())
	if t <= k:
		return t
	if t <= n:
		return k
	return n + k - t
print(solution())


(n, k, t) = input().strip().split(' ')
(n, k, t) = [int(n), int(k), int(t)]
if t <= k:
	ans = t
elif t <= n and t > k:
	ans = k
else:
	ans = k - (t - n)
print(ans)


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


(n, k, t) = map(int, input().split())
if t in range(0, k):
	print(t)
elif t in range(k, n + 1):
	print(k)
else:
	print(k - t % n)


q = lambda : map(int, input().split())
qi = lambda : int(input())
qs = lambda : input().split()
(n, k, t) = q()
if t <= k:
	print(t)
elif k < t <= n:
	print(k)
elif t > n:
	print(k - (t - n))


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


import math
import sys

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def minput():
	return map(int, input().split())

def listinput():
	return list(map(int, input().split()))
(n, k, t) = minput()
if k >= t and t < n:
	print(t)
elif t >= k and t < n or t == n:
	print(k)
else:
	t = t % n
	print(k - t)


class CodeforcesTask851ASolution:

	def __init__(self):
		self.result = ''
		self.n_k_t = []

	def read_input(self):
		self.n_k_t = [int(x) for x in input().split(' ')]

	def process_task(self):
		if self.n_k_t[1] <= self.n_k_t[2] <= self.n_k_t[0]:
			self.result = str(self.n_k_t[1])
		elif self.n_k_t[2] < self.n_k_t[1]:
			self.result = str(self.n_k_t[2])
		else:
			self.result = str(self.n_k_t[0] + self.n_k_t[1] - self.n_k_t[2])

	def get_result(self):
		return self.result
Solution = CodeforcesTask851ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


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


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


from sys import stdin
input = lambda : stdin.readline().strip()
(n, k, t) = map(int, input().split())
if t <= k:
	print(t)
elif k < t <= n:
	print(k)
else:
	print(n + k - t)


def process2(in_list):
	n = in_list[0]
	k = in_list[1]
	t = in_list[2]
	if t <= k:
		print(t)
	elif t <= n:
		print(k)
	else:
		print(k - (t - n))
in_list = list(map(int, input().split()))
process2(in_list)


def wave(n, k, t):
	if t <= k:
		return t
	if k < t <= n:
		return k
	if t > n + k:
		return 0
	if t > n:
		return n + k - t
(N, K, T) = [int(i) for i in input().split()]
print(wave(N, K, T))


(N, K, T) = map(int, input().split())
if T < K:
	print(T)
elif N < T:
	print(N + K - T)
else:
	print(K)


n = list(map(int, input().split()))
if n[2] < n[1]:
	print(n[2])
elif n[2] >= n[1] and n[2] <= n[0]:
	print(n[1])
else:
	print(n[0] + n[1] - n[2])


x = list(map(int, input().split(' ')))
if x[2] < x[1]:
	print(x[2])
elif x[2] < x[0]:
	print(x[1])
else:
	print(x[0] + x[1] - x[2])


l = list(map(int, input().split()))
t = l[2]
n = l[0]
k = l[1]
if t < k + 1:
	print(t)
	exit()
elif t < n + 1:
	print(k)
	exit()
else:
	print(n + k - t)


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


inp = input().split()
n = int(inp[0])
k = int(inp[1])
t = int(inp[2])
ans = 0
if t <= k:
	ans = t
elif t <= n:
	ans = k
else:
	ans = k - (t - n)
print(ans)


(n, k, t) = [int(s) for s in input().split(' ')]
print(min(t, k, n + k - t))


import sys

def main():
	(n, k, t) = map(int, sys.stdin.read().strip().split())
	if t > n:
		return n + k - t
	if t < k:
		return t
	return k
print(main())


a = input().split()
i = int(a[0])
j = int(a[1])
k = int(a[2])
if k < j:
	print(k)
elif k < i:
	print(j)
else:
	print(i + j - k)


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


f = input()
f1 = f.split(' ')
n = int(f1[0])
k = int(f1[1])
t = int(f1[2])
if t < k:
	print(t)
else:
	print(min(k, k - (t - n)))


string = input().split(' ')
n = int(string[0])
k = int(string[1])
t = int(string[2])
if t <= k:
	print(t)
elif t <= n:
	print(str(t - (t - k)))
else:
	print(str(n - (t - k)))


s = input()
ss = s.split()
n = int(ss[0])
k = int(ss[1])
t = int(ss[2])
b = 0
if t - k > 0:
	b = t - k
c = 0
if t - n > 0:
	c = t - n
print(t - b - c)


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


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


params = input().split(' ')
(n, k, t) = (int(params[0]), int(params[1]), int(params[2]))
print(min(t, n) - max(t - k, 0))


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


(n, k, t) = map(int, input().split())
print(min(t, n) - max(t - k, 0))


read = list(map(int, input().split()))
(n, k, t) = (read[0], read[1], read[2])
print(min(t, k, k - t + n))


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


(a, b, c) = map(int, input().split())
if c <= b:
	print(c)
elif c > b and c <= a:
	print(b)
else:
	d = c - a
	print(b - d if b - d >= 0 else 0)


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


mass = input().split()
n = int(mass[0])
k = int(mass[1])
t = int(mass[2])
if t <= k:
	print(t)
elif t <= n:
	print(k)
else:
	print(k - t % n)


import sys
import math
import bisect

def main():
	(n, k, t) = map(int, input().split())
	pos = [0 - k + 1, 0]
	pos[0] += t - 1
	pos[1] += t - 1
	pos[0] = max(pos[0], 0)
	pos[1] = min(pos[1], n - 1)
	ans = pos[1] - pos[0] + 1
	print(ans)
main()


import sys

def process2(in_list):
	n = in_list[0]
	k = in_list[1]
	t = in_list[2]
	if t <= k:
		print(t)
	elif t <= n:
		print(k)
	else:
		print(k - (t - n))
in_str = sys.stdin.readline().strip()
in_list = list(map(int, in_str.split(' ')))
process2(in_list)


(n, k, t) = map(int, input().split())
if n > t:
	print(min(n, k, t))
	exit(0)
print(n + k - t)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import gcd, ceil

def prod(a, mod=10 ** 9 + 7):
	ans = 1
	for each in a:
		ans = ans * each % mod
	return ans

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
for _ in range(int(input()) if not True else 1):
	(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) = map(int, input().split())
sitting = max(0, t - k)
if t > n:
	standing = n
else:
	standing = t
print(standing - sitting)


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


(a, b, c) = map(int, input().split())
print(min(b, c, a + b - c))


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


import math
import collections
import bisect
import heapq
import time
import random
import itertools
(N, K, T) = map(int, input().split())
if T <= K:
	print(T)
elif T <= N:
	print(K)
elif T <= N + K:
	print(N + K - T)
else:
	print(0)


def solve():
	a = input().split()
	n = int(a[0])
	k = int(a[1])
	t = int(a[2])
	if t <= k:
		return t
	elif t <= n:
		return k
	else:
		return n + k - t
print(solve())


from sys import stdin, stdout
(n, k, t) = map(int, stdin.readline().rstrip().split())
print(max([min([n, t]) - max([0, t - k]), 0]))


def main(n, k, t):
	if t == 0 or t == n + k:
		return 0
	if t <= n:
		return min(t, k)
	return k - (t - n)
(n, k, t) = map(int, input().split(' '))
print(main(n, k, t))


take = input().split(' ')
total = int(take[0])
k = int(take[1])
time = int(take[2])
if time <= k:
	print(time)
elif time > k and time <= total:
	print(k)
elif time > k and time > total:
	diff = time - total
	print(k - diff)


def solution(l1):
	t = l1[2]
	k = l1[1]
	n = l1[0]
	if t <= k:
		return t
	elif t <= n:
		return k
	else:
		return n + k - t

def answer():
	l1 = [int(x) for x in input().split()]
	print(solution(l1))
answer()


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


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


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


(a, b, c) = map(int, input().split())
print(c if b >= c else b if a >= c + 1 else b - (c - a))


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


(n, k, t) = map(int, input().split())
ans = k
ans -= [0, k - t][t < k]
ans -= [0, t - n][t > n]
print(ans)


import sys

def num_spectators_standing(n, k, t):
	if n >= t >= k:
		return k
	if t < k:
		return t
	if t > n:
		return k - (t - n)

def main():
	(n, k, t) = map(int, sys.stdin.readline().strip().split(' '))
	print(num_spectators_standing(n, k, t))
	assert num_spectators_standing(10, 5, 3) == 3
	assert num_spectators_standing(10, 5, 7) == 5
	assert num_spectators_standing(10, 5, 12) == 3
main()


Input = input().split()
n = int(Input[0])
k = int(Input[1])
t = int(Input[2])
if t <= k:
	print(t)
elif t <= n:
	print(k)
elif t > n:
	print(k - (t - n))


(m, n, o) = map(int, input().split())
if o < n:
	print(o)
elif o >= n and o <= m:
	print(n)
else:
	print(n + m - o)


import sys
[n, k, t] = list(map(int, sys.stdin.readline().split()))

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


[n, k, t] = list(map(int, input().strip().split()))
if min(n, k, t) == t:
	ans = t
elif t > k and t < n:
	ans = k
elif max(n, k, t) == t:
	ans = n - t + k
print(ans)


import sys
import math
lines = sys.stdin.read().splitlines()
(n, k, t) = [int(x) for x in lines[0].split()]
if t > n:
	print(max(0, k - (t - n)))
else:
	print(min(k, t))


s = input().split()
a = [int(i) for i in s]
if a[1] > a[2]:
	print(a[2])
elif a[2] <= a[0]:
	print(a[1])
else:
	print(a[1] + a[0] - a[2])


(x, y, z) = map(int, input().split())
if z < y:
	print(z)
elif z >= y and z <= x:
	print(y)
else:
	print(y - (z - x))


s = input().split()
(n, k, t) = (int(s[0]), int(s[1]), int(s[2]))
print(min(t, k, n + k - t))


from sys import stdin, stdout

def main():
	t = stdin.readline().split()
	n = int(t[0])
	k = int(t[1])
	t = int(t[2])
	if t > n:
		print(abs(n - (t - k)))
	elif t > k:
		print(k)
	else:
		print(t)
main()


from math import *
(n, k, t) = map(int, input().split())
if t >= k and t <= n:
	print(k)
else:
	print(min(t, n + k - t))


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


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


(n, k, t) = map(int, input().split())
ans = min(k, t)
if t > n:
	ans = k - (t - n)
print(ans)


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


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


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


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


(n, k, t) = map(int, input().split())
first = max(1, min(n, t))
last = max(1, min(n, t - k + 1))
print(first - last + 1)


(a, b, c) = input().split()
(a, b, c) = (int(a), int(b), int(c))
if c < b:
	print(c)
elif c > a + b:
	print(0)
elif c >= a:
	print(b - c % a)
else:
	print(b)


import sys, math
input = sys.stdin.readline
L = lambda : list(map(int, input().split()))
M = lambda : map(int, input().split())
l = L()
if l[2] <= l[1]:
	print(l[2])
elif l[2] > l[0]:
	print(l[1] - l[2] % l[0])
else:
	print(l[1])


(a, b, c) = map(int, input().split())
op = a + b - c
if op > b:
	if c < b:
		print(c)
	else:
		print(b)
elif op > b:
	print(b)
else:
	print(op)


L = input()
L = L.split()
n = int(L[0])
k = int(L[1])
t = int(L[2])
b = True
p = k
if t < k + 1:
	print(t)
if t > k and t <= n:
	print(k)
j = t - n
while t > n and j <= p:
	k -= j
	print(k)
	break


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


p = list(map(int, input().split()))
print(p[2] if p[1] >= p[2] else p[1] if p[2] > p[1] and p[2] <= p[0] else p[1] - (p[2] - p[0]))


import sys
import os
import math
import re
(n, k, t) = map(int, input().split())
print(min(min(n + k - t, k), t))


def test_0():
	import math
	from collections import Counter
	(n, k, t) = list(map(int, input().split(' ')))
	if t < k:
		print(t)
	elif t >= n:
		if t - n + 1 <= k:
			print(k - (t - n))
		else:
			print(0)
	else:
		print(k)
test_0()


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


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


def inp(a, n):
	s = ''
	j = 1
	for i in a:
		if i != ' ' and j <= n:
			s += i
		else:
			j += 1
			if j > n:
				break
			else:
				s = ''
	if s != '':
		c = int(s)
	else:
		c = 0
	return c
a = input()
n = int(inp(a, 1))
k = int(inp(a, 2))
t = int(inp(a, 3))
if k > t:
	print(t)
elif t > n:
	print(n + k - t)
else:
	print(k)


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


b = list(map(int, input().split()))
if b[2] <= b[1] and b[2] >= 1:
	print(b[2])
elif b[2] > b[1] and b[2] < b[0]:
	print(b[1])
elif b[2] >= b[0] and b[2] < b[0] + b[1]:
	print(b[0] - b[2] + b[1])


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


(n, k, t) = [int(i) for i in input().split()]
print(min(t, k, n + k - t))


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


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


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

def s():
	if t <= k:
		return t
	if t <= n:
		return k
	return n + k - t
print(s())


def main():
	from sys import stdin, stdout
	(n, k, t) = map(int, stdin.readline().split())
	if t == 0:
		stdout.write('0')
	elif t > k:
		if t > n:
			stdout.write(str(n - (t - k)))
		else:
			stdout.write(str(k))
	else:
		stdout.write(str(t))
main()


l = input().split()
n = int(l[0])
k = int(l[1])
t = int(l[2])
stand = 0
if t <= k:
	stand = t
elif t > k and t <= n:
	stand = k
else:
	stand = k - (t - n)
print(stand)


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)


T_ON = 0
DEBUG_ON = 1
MOD = 998244353

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

def main():
	T = read_int() if T_ON else 1
	for i in range(T):
		solve()

def debug(*xargs):
	if DEBUG_ON:
		print(*xargs)
from collections import *
import math
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def read_int():
	return int(input())

def read_ints():
	return list(map(int, input().split()))

def print_nums(nums):
	print(' '.join(map(str, nums)))

def YES():
	print('YES')

def Yes():
	print('Yes')

def NO():
	print('NO')

def No():
	print('No')

def First():
	print('First')

def Second():
	print('Second')

def fib(n):
	(a, b) = (0, 1)
	for _ in range(n):
		(a, b) = (b, a + b)
	return a

def fib_ns(n):
	assert n >= 1
	f = [0 for _ in range(n + 1)]
	f[0] = 0
	f[1] = 1
	for i in range(2, n + 1):
		f[i] = f[i - 1] + f[i - 2]
	return f

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def xgcd(a, b):
	(x0, x1, y0, y1) = (0, 1, 1, 0)
	while a != 0:
		((q, a), b) = (divmod(b, a), a)
		(y0, y1) = (y1, y0 - q * y1)
		(x0, x1) = (x1, x0 - q * x1)
	return (b, x0, y0)

def lcm(a, b):
	d = gcd(a, b)
	return a * b // d

def is_even(x):
	return x % 2 == 0

def is_odd(x):
	return x % 2 == 1

def modinv(a, m):
	(g, x, _) = xgcd(a, m)
	if g != 1:
		raise Exception('gcd(a, m) != 1')
	return x % m

def mod_add(x, y):
	x += y
	while x >= MOD:
		x -= MOD
	while x < 0:
		x += MOD
	return x

def mod_mul(x, y):
	return x * y % MOD

def mod_pow(x, y):
	if y == 0:
		return 1
	if y % 2:
		return mod_mul(x, mod_pow(x, y - 1))
	p = mod_pow(x, y // 2)
	return mod_mul(p, p)

def mod_inv(y):
	return mod_pow(y, MOD - 2)

def mod_div(x, y):
	return mod_mul(x, mod_inv(y))

def is_prime(n):
	if n == 1:
		return False
	for i in range(2, int(n ** 0.5) + 1):
		if n % i:
			return False
	return True

def gen_primes(n):
	P = [True for _ in range(n + 1)]
	P[0] = P[1] = False
	for i in range(int(n ** 0.5) + 1):
		if P[i]:
			for j in range(2 * i, n + 1, i):
				P[j] = False
	return P
main()


(n, k, t) = map(int, input().split())
standing = min(k, n)
standing = min(t, k)
if t > n:
	visible = max(0, k - (t - n))
	standing = min(standing, visible)
print(standing)


(x, y, z) = map(int, input().split())
print(min(z, min(y, y - (z - x))))


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)


(a, b, c) = map(int, input().split())
if c <= a:
	print(min(b, c))
else:
	print(a + b - c)


def reversed_list(l, start, end):
	if start >= end:
		return l
	(l[start], l[end]) = (l[end], l[start])
	return reversed_list(l, start + 1, end - 1)

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


(a, b, c) = [int(i) for i in input().split()]
if c <= b:
	print(c)
elif c > a:
	print(b + a - c)
else:
	print(b)