import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); if (a == 0 && b == 0) { System.out.println(0); } int ansA = Integer.MAX_VALUE; int ansB = Integer.MAX_VALUE; for (int i = 0; i <= 200; i++) { for (int j = 0; j <= 200; j++) { if (i == 0 && j == 0) { continue; } int tmpA = 1000 * i / (i + j); if (tmpA % 10 >= 5) { tmpA += 10; } tmpA /= 10; int tmpB = 1000 * j / (i + j); if (tmpB % 10 >= 5) { tmpB += 10; } tmpB /= 10; if (tmpA == a && tmpB == b) { ansA = Math.min(ansA, i); ansB = Math.min(ansB, j); break; } } } System.out.println(ansA + ansB); } }