#include <bits/stdc++.h>
using namespace std;
const int INF = 2000000000;
const long long LINF = 4000000000000000000ll;
const double EPS = 1e-9;
const int MAXN = 100000;
int a[MAXN];
int main() {
  int n, k, t;
  cin >> n >> k >> t;
  if (t < k)
    cout << t;
  else if (t > n)
    cout << k - t + n;
  else
    cout << k;
  return 0;
}
