#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, t;
  cin >> n >> m >> t;
  if (t <= m) {
    cout << min(t, n) << endl;
    return 0;
  } else if (t > m && t <= n) {
    cout << m << endl;
    return 0;
  } else if (t >= n && t <= m + n) {
    cout << m - (t - n) << endl;
    return 0;
  } else {
    cout << "0" << endl;
    return 0;
  }
}
