#include #include #include #include #include #include #include #include const int mod = 1e9 + 7; const int INF = 1e9; using namespace std; typedef long long ll; int main() { int l,r,m; cin >> l >> r >> m; if(r - l >= m){ cout << m; }else{ cout << r - l; } }