링크 : https://www.acmicpc.net/problem/1476
/*
문제 : 날짜 계산
링크 : https://www.acmicpc.net/problem/1476
*/
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> v;
int main(){
int E, S, M;
cin >> E >> S >> M;
int year = 1;
while(1){
if((year - E) % 15 == 0 && (year - S) % 28 == 0 && (year - M) % 19 == 0) break;
else year++;
}
cout << year;
return 0;
}