import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int x = sc.nextInt(); int y = sc.nextInt(); int[] counts = new int[y + 1]; int max = 0; for (int i = 0; i * i <= y; i++) { int di = i * i; for (int j = i; di + j * j <= y; j++) { int dj = di + j * j; if (dj < x) { continue; } int by; if (i == 0 || i == j) { by = 1; } else { by = 2; } counts[dj] += by; max = Math.max(max, counts[dj]); } } System.out.println(max * 4); } }