#include using namespace std; int main(){ int L,R,M; if(L - R + 1 > M){ cout << M << endl; } else{ cout << L - R + 1 << endl; } return 0; }