import java.io.* ; public class cakes { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)) ; while (true) { String[] f = br.readLine().split(" ") ; if (f.length < 2) break ; boolean b[][] = new boolean[500][500] ; b[0][0] = true ; int sum = 0 ; for (int i=1; i=0; j--) for (int k=499; k>=0; k--) b[j][k] |= (j >= ct && b[j-ct][k]) | (k >= ct && b[j][k-ct]) ; } int r = 500 ; for (int i=0; i