import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int[] a = new int[3]; for (int i = 0; i < 3; i++) { a[i] = sc.nextInt(); } sc.close(); int g = 0; for (int i = 0; i < 3; i++) { g = gcd(g, a[i]); } if (g > 1) { System.out.println("INF"); return; } Arrays.sort(a); int[][] c = new int[3][a[2]]; for (int i = 0; i < 3; i++) { Arrays.fill(c[i], Integer.MAX_VALUE); int i2 = (i + 1) % 3; for (int j = 1; j < a[i]; j++) { int x = 0; int end = a[i] * a[i2] / gcd(a[i], a[i2]); while (x < end) { x += a[i2]; if (x % a[i] == j) { c[i][j] = Math.min(c[i][j], x / a[i]); break; } } } } int lcm = 1; for (int i = 0; i < 3; i++) { lcm = lcm(lcm, a[i]); } for (int i = 1; i < 3; i++) { for (int j = 1; j < a[0]; j++) { for (int j2 = 1; j2 < a[i]; j2++) { if (c[i][j2] == Integer.MAX_VALUE) { continue; } int x = a[i] * c[i][j2] + j2; int end = lcm * 2; if (c[0][j] != Integer.MAX_VALUE) { end = Math.min(end, a[0] * c[0][j] + j); } while (x < end) { if (x % a[0] == j) { c[0][j] = Math.min(c[0][j], x / a[0]); break; } x += a[i]; } } } } int ans = 0; for (int i = 1; i < a[0]; i++) { if (c[0][i] == Integer.MAX_VALUE) { System.out.println("INF"); return; } ans += c[0][i]; } System.out.println(ans); } static int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } static int lcm(int a, int b) { return a * b / gcd(a, b); } }