import java.io.*; import java.util.*; public class Main { static Jewel[] jewels; static long[][] dp; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int m = sc.nextInt(); jewels = new Jewel[n]; for (int i = 0; i < n; i++) { jewels[i] = new Jewel(sc.nextInt(), sc.nextInt()); } Arrays.sort(jewels); dp = new long[n][m + 1]; for (long[] arr : dp) { Arrays.fill(arr, -1); } long ans = 0; for (int i = 0; i < n; i++) { ans = Math.max(ans, (dfw(i - 1, m - jewels[i].weight) + jewels[i].value) * jewels[i].value); } System.out.println(ans); } static long dfw(int idx, int w) { if (w < 0) { return Integer.MIN_VALUE; } if (idx < 0) { return 0; } if (dp[idx][w] < 0) { dp[idx][w] = Math.max(dfw(idx - 1, w), dfw(idx - 1, w - jewels[idx].weight) + jewels[idx].value); } return dp[idx][w]; } static boolean getEnable(int x, int y) { if (x == y) { return true; } if (x > y) { return false; } for (int i = 2; i <= Math.sqrt(y); i++) { if (y % i > 0) { continue; } if (getEnable(x, i + y / i)) { return true; } } return false; } static class Jewel implements Comparable { int value; int weight; public Jewel(int value, int weight) { this.value = value; this.weight = weight; } public int compareTo(Jewel another) { return another.value - value; } } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }