import java.util.Arrays; import java.util.Scanner; public class Main { public static boolean judge(int x) { int a = x * x * x; int b = x * x * x * x; boolean vis[] = new boolean[10]; if (a < 1000 || a > 9999) return false; if (b < 100000 || b > 999999) return false; while (a > 0) { vis[a % 10] = true; a /= 10; } while (b > 0) { vis[b % 10] = true; b /= 10; } for (int i = 0; i < 10; i++) if (!vis[i]) return false; return true; } public static void main(String[] args) { Scanner scan = new Scanner(System.in); for (int i = 1; i <= 1000; i++) { if (judge(i)) { System.out.println(i); break; } } } }