#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long INF = 1e12;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, k, t;
  cin >> n >> k >> t;
  long long ans = min(k, t);
  ans = min(ans, min(k, n + k - t));
  cout << ans << endl;
}
