#include<iostream>
using namespace std;
int main()
{
int a, b;
while(cin>>a>>b)
{
if(a==0)
{
cout<<"0"<<endl;
}
else if(a==1||a==3||a==4)
{
if(b<10)
{
cout<<"0"<<endl;
}
else if(10<=b&&b<30)
{
cout<<(b-10)*3+1<<endl;
}
else if(30<=b&&b<70)
{
cout<<(b-10)*3+2<<endl;
}
else if(70<=b&&b<120)
{
cout<<(b-10)*3+3<<endl;
}
else if(120<=b&&b<=200)
{
cout<<(b-10)*3+6<<endl;
}
}
else if(a==2)
{
if(b<8)
{
cout<<"0"<<endl;
}
else if(8<=b&&b<30)
{
cout<<(b-8)*3+1<<endl;
}
else if(30<=b&&b<70)
{
cout<<(b-8)*3+2<<endl;
}
else if(70<=b&&b<120)
{
cout<<(b-8)*3+3<<endl;
}
else if(120<=b&&b<=200)
{
cout<<(b-8)*3+6<<endl;
}
}
}
}