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;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long fact(long long j) {
  long long a = 1;
  for (long long i = 1; i <= j; i++) a *= i;
  return a;
}
long long pw(long long a, long long b) {
  if (b == 0) return 1;
  if (b % 2)
    return pw(a, b - 1) * a;
  else {
    long long x = pw(a, b / 2);
    return x * x;
  }
}
long long sum2(long long c) {
  long long s = 0;
  while (c != 0) {
    s += (c % 10) * (c % 10);
    c /= 10;
  }
  return s;
}
vector<int> merge(const vector<int> &a, const vector<int> &b) {
  long long p1 = 0, p2 = 0;
  vector<int> c;
  for (; p1 < a.size() && p2 < b.size();)
    if (a[p1] == b[p2]) {
      c.push_back(a[p1]);
      p1++;
      p2++;
    } else if (a[p1] < b[p2])
      p1++;
    else
      p2++;
  return c;
}
bool prime(long long a) {
  if (a == 0 || a == 1) return false;
  for (int i = 2; i <= sqrt(a); i++)
    if (a % i == 0) return false;
  return true;
}
long long C(long long n, long long k) {
  vector<vector<long long> > dp(n + 1, vector<long long>(n + 1, 1));
  for (int i = 0; i < (n + 1); i++) {
    for (int j = 1; j < i; j++) {
      dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];
    }
  }
  return dp[n][k];
}
struct st {
  int h, m, s;
};
bool operator<(st A, st B) {
  return (A.h < B.h || A.h == B.h && A.m < B.m ||
          A.h == B.h && A.m == B.m && A.s < B.s);
}
bool cmp(long long a, long long b) {
  if (a % 10 < b % 10) return true;
  if (a % 10 > b % 10) return false;
  if (a % 10 == b % 10) {
    return (a < b);
  }
}
long long phi(long long n) {
  long long ans = n;
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0) {
      while (n % i == 0) n /= i;
      ans -= ans / i;
    }
  if (n > 1) ans -= ans / n;
  return ans;
}
vector<long long> rech(200005, 1);
void reh() {
  rech[0] = 0;
  rech[1] = 0;
  for (long long i = 2; i < 100000; i++)
    for (long long j = i * i; j < 100000; j += i)
      if (rech[j]) rech[j] = 0;
}
struct Node {
  long long i, mx;
};
Node tr[4 * 1000000 + 10];
void build(vector<long long> &a, long long v, long long l, long long r) {
  if (l == r)
    tr[v].i = l, tr[v].mx = a[l];
  else {
    long long m = (l + r) / 2;
    build(a, 2 * v, l, m);
    build(a, 2 * v + 1, m + 1, r);
    if (tr[2 * v].mx >= tr[2 * v + 1].mx)
      tr[v].i = tr[2 * v].i, tr[v].mx = tr[2 * v].mx;
    else
      tr[v].i = tr[2 * v + 1].i, tr[v].mx = tr[2 * v + 1].mx;
  }
}
Node find(long long x, long long y, long long v, long long l, long long r) {
  if (x == l && y == r) return tr[v];
  long long m = (l + r) / 2;
  if (y <= m)
    return find(x, y, 2 * v, l, m);
  else if (x > m)
    return find(x, y, 2 * v + 1, m + 1, r);
  else {
    Node a, b, c;
    a = find(x, m, 2 * v, l, m);
    b = find(m + 1, y, 2 * v + 1, m + 1, r);
    if (a.mx >= b.mx)
      c.i = a.i, c.mx = a.mx;
    else
      c.i = b.i, c.mx = b.mx;
    return c;
  }
}
void update(long long i, long long x, long long v, long long l, long long r) {
  if (l == r) {
    if (tr[v].mx != 0)
      tr[v].mx = x;
    else
      return;
  } else {
    long long m = (l + r) / 2;
    if (i <= m)
      update(i, x, 2 * v, l, m);
    else
      update(i, x, 2 * v + 1, m + 1, r);
    if (tr[2 * v].mx >= tr[2 * v + 1].mx)
      tr[v].i = tr[2 * v].i, tr[v].mx = tr[2 * v].mx;
    else
      tr[v].i = tr[2 * v + 1].i, tr[v].mx = tr[2 * v + 1].mx;
  }
}
struct cir {
  long long x, y, r;
};
int main() {
  long long n, k, t;
  cin >> n >> k >> t;
  if (t < k)
    cout << t << endl;
  else if (t > n)
    cout << k - t + n << endl;
  else
    cout << k << endl;
  return 0;
}
