#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, m, i, j, k, flag = 0, t;
  cin >> n >> k >> t;
  if (t <= k)
    m = t;
  else if (t <= n)
    m = k;
  else
    m = k + n - t;
  cout << m;
  return 0;
}
