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. 
#include <bits/stdc++.h>
using namespace std;
void input_File() {}
bool isPrime(long long n) {
  if (n <= 1) return false;
  for (long long i = 2; i < n; i++)
    if (n % i == 0) return false;
  return true;
}
long long sumofdigits(long long n) {
  long long c = 0;
  while (n > 0) {
    c++;
    n /= 10;
  }
  return c;
}
long long MaxSubArraySumReturn(long long a[], long long n) {
  long long sum = 0, best = 0;
  for (long long i = 0; i < n; i++) {
    sum = max(a[i], a[i] + sum);
    best = max(best, sum);
  }
  return best;
}
long long fact(long long n) {
  long long res = 1;
  for (long long i = 2; i <= n; i++) res = res * i;
  return res;
}
long long nCr(long long n, long long r) {
  return fact(n) / (fact(r) * fact(n - r));
}
bool sortinrev(const pair<long long, long long> &a,
               const pair<long long, long long> &b) {
  return (a.first > b.first);
}
long long countDivisors(long long n) {
  long long cnt = 0;
  for (long long i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i)
        cnt++;
      else
        cnt = cnt + 2;
    }
  }
  return cnt;
}
long long setBitCount(long long n) {
  long long ans = 0;
  while (n) n &= n - 1, ans++;
  return ans;
}
long long power(long long a, long long b) {
  long long result = 1;
  while (b) {
    if (b & 1) {
      result *= a;
      b--;
    } else {
      a *= a;
      b >>= 1;
    }
  }
  return result;
}
long long recursive(long long n) {
  if (n == 0) return 0;
  return n + recursive(n / 2);
}
long long MOD = (long long)1e9 + 7;
void solve() {
  long long n, k, t;
  cin >> n >> k >> t;
  if (t <= k) {
    cout << t << "\n";
    return;
  }
  if (t >= n + k) {
    cout << 0 << "\n";
    return;
  }
  if (t >= k and t <= n) {
    cout << k << "\n";
    return;
  }
  if (t > n) {
    long long diff = t - n;
    if (k - diff >= 0)
      cout << k - diff << "\n";
    else
      cout << 0 << "\n";
  }
}
signed main() {
  input_File();
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long isTestCasePresent = 0;
  if (isTestCasePresent == 0) {
    long long t = 1;
    while (t--) {
      solve();
    }
  } else {
    long long t;
    cin >> t;
    while (t--) {
      solve();
    }
  }
  return 0;
}
