#include <bits/stdc++.h>
using namespace std;
long long arr[1000010];
int main() {
  long long t, i, j, k, n, m;
  string str;
  cin >> n >> k >> t;
  if (t < k)
    cout << t;
  else if (t >= k and t <= n)
    cout << k;
  else
    cout << k - (t - n);
}
