#include <iostream>
using namespace std;
bool isleap(int y)
{
	if((y%4==0)&&((y%100!=0)||(y%400==0)))
		return true;
	else
		return false;
}
int main(void)
{
	int y,m,d;
	cin>>y>>m>>d;
	int r;
	//count days between 20130809 and ymd

	int y0=y;
	int m0=m;
	int d0=d;
	r=0;
	int i;

	int p[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	int pp[12]={31,29,31,30,31,30,31,31,30,31,30,31};

	for(i=y;i<2014;i++)
	{
		if(isleap(i))
		{
			int j;
			for(j=m;j<13;j++)
			{
				int k;

				for(k=d;k<=pp[j-1];k++)
				{	
					r++;
				}
				d=1;
				
			}
		}
		else
		{
			int j;
			for(j=m;j<13;j++)
			{
				int k;
				for(k=d;k<=p[j-1];k++)
				{	
					
					if(k==9&&j==8&&i==2013)
						if(r!=0)
						{
							cout<<((5-r%7)>0?(5-r%7):(12-r%7));
							system("pause");
							return 0;
						}
					r++;
				}
				d=1;
			}
		}
		m=1;
	}

	d=9;
	m=8;
	y=2013;

	r=0;
	for(i=y;i<y0+1;i++)
	{
		if(isleap(i))
		{
			int j;
			for(j=m;j<13;j++)
			{
				int k;

				for(k=d;k<=pp[j-1];k++)
				{	
					
					if(k==d0&&j==m0&&i==y0)
						if(r!=0)
						{
							cout<<((5+r%7)>7?(r%7-2):(5+r%7));
							system("pause");
							return 0;
						}
					r++;
				}
				d=1;
			}
		}
		else
		{
			int j;
			for(j=m;j<13;j++)
			{
				int k;
				for(k=d;k<=p[j-1];k++)
				{	
					//r++;
					if(k==d0&&j==m0&&i==y0)
						if(r!=0)
						{
							cout<<((5+r%7)>7?(r%7-2):(5+r%7));

							system("pause");
							return 0;
						}
					r++;
				}
				d=1;
			}
		}
		m=1;
	}
	
	
	cout<<5;
	system("pause");
	return 0;
}