#include <bits/stdc++.h>
using namespace std;
ofstream fo("test.out");
ifstream fi("test.inp");
int n, k, t;
int main() {
  cin >> n >> k >> t;
  if (t <= k)
    cout << t;
  else {
    if (t <= n)
      cout << k;
    else
      cout << k - t + n;
  }
}
