import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;
public class boj1476 {
static int E, S, M;
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
E = Integer.parseInt(st.nextToken());
S = Integer.parseInt(st.nextToken());
M = Integer.parseInt(st.nextToken());
int res = 1;
int e = 1, s = 1, m = 1;
while(true){
if( e > 15 ) e = 1;
if( s > 28 ) s = 1;
if( m > 19 ) m = 1;
if(e == E && s == S && m == M) break;
e++;
s++;
m++;
res++;
}
System.out.println(res);
}
}
Leave a comment