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[a[0]]; Arrays.fill(c, Integer.MAX_VALUE); for (int i = 1; i < 3; i++) { for (int j = 1; j < c.length; j++) { int x = 0; int end = a[0] * a[i] / gcd(a[0], a[i]); while (x < end) { x += a[i]; if (x % a[0] == j) { c[j] = Math.min(c[j], x / a[0]); break; } } } } int ans = 0; for (int i = 1; i < c.length; i++) { if (c[i] == Integer.MAX_VALUE) { System.out.println("INF"); return; } ans += c[i]; } System.out.println(ans); } static int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } }