/*
#include <stdio.h>
int main()
{
int a,s;
scanf("%d %d",&a,&s);
if(a%5==0)
{
printf("%d",(90-a)/5+s);
}
else
{
printf("%d",(90-a)/5+s+1);
}
return 0;
}
#include <stdio.h>
int main()
{
int a,b,c;
scanf("%d",&a);
b=a/10;
c=a%10;
a=(10*c+b)*2%100;
if(a<=50)
{
printf("%d\nGOOD",a);
}
else
{
printf("%d\nOH MY GOD",a);
}
return 0;
}
#include <stdio.h>
int main()
{
int a,b,c,s,w;#include <stdio.h>
int main()
{
int a,b,c,s,w;
scanf("%d %d %d",&a,&b,&c);
s=(a+b+c)%1000;
w=s/100;
if(w%2==0)
{
printf("대박");
}
else
{
printf("그럭저럭");
}
return 0;
}
*/
#include <stdio.h>
int main()
{
int a,b,s;
scanf("%d %d",&a,&b);
s=a/10000;
if(b==1||b==2)
{
s=s+1900;
}
else
{
s=s+2000;
}
//s=태어난 연도
printf("%d",2012-s+1);
return 0;
}