package BOJ.BruteForce;
import java.util.Scanner;
public class BOJ_1476 {
public static void main(String[] args) {
java.util.Scanner sc = new Scanner(System.in);
int[] dsm = new int[3];
for (int i = 0; i < 3; i++) {
dsm[i] = sc.nextInt();
}
int count = 0;
int d = 0;
int s = 0;
int m = 0;
while (true) {
if (d == dsm[0] && s == dsm[1] && m == dsm[2])
break;
d++;
if (d % (15 + 1) == 0)
d = 1;
s++;
if (s % (28 + 1) == 0)
s = 1;
m++;
if (m % (19 + 1) == 0)
m = 1;
count++;
}
System.out.println(count);
}
}