#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e6 + 5, M = 1e9 + 7;
void solve() {
  int n, k, t;
  cin >> n >> k >> t;
  if (t <= k) {
    cout << t;
  } else if (t > n) {
    cout << k - (t - n);
  } else {
    cout << k;
  }
}
int main() {
  ios ::sync_with_stdio(0);
  cin.tie(0);
  int tt = 1;
  while (tt--) {
    solve();
    cout << '\n';
  }
  return 0;
}
