#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 100, maxm = 1e5 + 100, inf = 0x3f3f3f3f, mod = 1e9 + 7;
const long long INF = 1e18 + 7;
struct edge {
  int from, to;
  long long w;
};
vector<edge> G[maxn];
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    q;
int main() {
  int n, k, t;
  scanf("%d%d%d", &n, &k, &t);
  if (n >= t) {
    if (t >= k)
      printf("%d", k);
    else
      printf("%d\n", t);
  } else {
    if (k >= t - n)
      printf("%d\n", k - (t - n));
    else
      printf("0\n");
  }
  return 0;
}
