#include <iostream>
using namespace std;
int main() {
int year, month, day;
cin>>year;
cin>>month;
cin>>day;
month=month-2;
if(month<=0)
{
month+=12;
year--;
}
month=month*83/32;
month+=day;
month+=year;
month+=year/4;
month-=year/100;
month+=year/400;
month=month%7;
cout<<month;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CglpbnQgeWVhciwgbW9udGgsIGRheTsKCWNpbj4+eWVhcjsKCWNpbj4+bW9udGg7CgljaW4+PmRheTsKCW1vbnRoPW1vbnRoLTI7CglpZihtb250aDw9MCkKCXsKCQltb250aCs9MTI7CgkJeWVhci0tOwoJfQoJbW9udGg9bW9udGgqODMvMzI7Cgltb250aCs9ZGF5OwoJbW9udGgrPXllYXI7Cgltb250aCs9eWVhci80OwoJbW9udGgtPXllYXIvMTAwOwoJbW9udGgrPXllYXIvNDAwOwoJbW9udGg9bW9udGglNzsKCWNvdXQ8PG1vbnRoOwoJCgkKCXJldHVybiAwOwp9