import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] arr = br.readLine().split(" ");
        int[] esm = new int[4];
        int e = 1; int s = 1; int m = 1;
        
        for(int i=1; i<=3; i++) { esm[i] = Integer.parseInt(arr[i-1]); }
        
        for(int i=1; i<=7980; i++) {
            if(e==esm[1] && s==esm[2] && m==esm[3]) {
                System.out.println(i);
                return;
            }
            
            e++; s++; m++;
            
            e = (e-1)%15+1;
            s = (s-1)%28+1;
            m = (m-1)%19+1;
        }
    }
}

'Problem Solving > BOJ' 카테고리의 다른 글

[Gold 5] 14500번 테트로미노  (0) 2022.04.01
[Gold 5] 1107번 리모컨  (0) 2022.04.01
[Silver 3] 3085번 사탕 게임  (0) 2022.04.01
[Gold 4] 17404번 RGB거리 2  (0) 2022.03.29
[Gold 5] 2133번 타일 채우기  (0) 2022.03.29