#include <bits/stdc++.h>
using namespace std;
int main()
{
int c, w;
while (cin >> c >> w){
if (c+w-1<12 || w==0){
cout << 0 << '\n';
}
else {
int sum=c+w-1, count=0;
while (sum>=12 && w>=1){
w = w-1;
if (c>=12){
c -= 12;
}
else if (c<12){
w = w-(12-c);
c = 0;
}
c = c+2;
sum = c+w;
count++;
}
cout << count << '\n';
}
}
return 0;
}