import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int e = sc.nextInt();
int s = sc.nextInt();
int m = sc.nextInt();
int cnt = 0;
while (true) {
if ((cnt % 15) + 1 == e && (cnt % 28) + 1 == s && (cnt % 19) + 1 == m) {
cnt++;
break;
}
cnt++;
}
System.out.println(cnt);
}
}
cnt
값과 같으면 값을 1 증가시키고 반복 종료