#include
using namespace std;
int main(){
int X,Y; // X-withdraw cash, Y-account balance.
cin >> X;
if(X%5!=0){X=0;}
cin>>Y;
if (Y<(X+0.5)){cout << (Y)<<endl;}
if (X!=0){
if (Y>(X+0.5)){cout << (Y-X-0.5)<<endl;}
}
else {cout << Y << endl;}
return 0;
}