#include<bits/stdc++.h>usingnamespace std;int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};int mm[10]={1,5,10,10,10,12};int dd[10]={1,1,1,2,3,25};intnextday(int&m,int&d){if(d == a[m]){///到每月最后一天
d=1; m++;}else d++;return0;}intmain(){int y,w,m,d,f;
cin >> y;if(y %4==0&& y %100!=0|| y %400==0)
a[2]=29;for(int i =6; i <10; i++){
cin >> mm[i]>> dd[i];}
cin >> w;
m =1;
d =1;
f =0;///标记春节天数int ans =0;///假期天数while(m !=13){if(m == mm[6]&& d == dd[6]){///判断为春节第一天
ans++;
f =2;}elseif(f){//其余两天无法在数组中匹配,so就搞一个f标记一下
ans++;
f--;}elseif(w ==6|| w ==7){
ans++;}else{for(int i =0; i <10; i++){///判断其他节日if(m == mm[i]&& d == dd[i]){
ans++;break;}}}nextday(m,d);
w++;if(w ==8){
w =1;}}
cout << ans;return0;}