#include <bits/stdc++.h>
const long double eps = 0.00000001;
const long long MOD = 1e9 + 7;
using namespace std;
int ans;
bool b;
string second;
int main() {
  fflush(stdin);
  cout << fixed, cout.precision(18);
  ios_base::sync_with_stdio(false);
  long long n, k, t;
  cin >> n >> k >> t;
  if (t < k)
    cout << t;
  else if (t > n)
    cout << n + k - t;
  else
    cout << k;
}
