#include<bits/stdc++.h>
using namespace std;
int m,r,ans;
int month[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int main(){
scanf("%d-%d",&m,&r);
if(m>12){
if(m%10==1){
m=1;
}
else if(m%10==2){
m=12;
}
else if(m%10==0){
m=10;
}
else{
m%=10;
}
ans++;
}
if(r!=month[m])ans++;
cout << ans;
return 0;
}