#include <bits/stdc++.h>
using namespace std;
int n, w;
pair<long long, long long> a[200];
long long memo[101][401][101];
long long solve(int i, int sum, int k) {
  if (i == n) return 0;
  long long &ret = memo[i][sum][k];
  if (ret != -1) return ret;
  long long x1 = 0, x2 = 0;
  x1 = solve(i + 1, sum, k);
  if (k > 0 && a[i].first <= sum) {
    x2 = a[i].second + solve(i + 1, sum - a[i].first, k - 1);
  }
  return ret = max(x1, x2);
}
int main() {
  memset(memo, -1, sizeof(memo));
  cin >> n >> w;
  long long minx = 1e9, maxx = 0;
  for (int i = 0; i < n; i++) {
    long long x, y;
    scanf("%I64d%I64d", &x, &y);
    minx = min(minx, x);
    maxx = max(maxx, x);
    a[i] = make_pair(x, y);
  }
  for (int i = 0; i < n; i++) {
    a[i].first -= minx;
  }
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    long long R = w - i * minx;
    R = min(R, 1LL * 400);
    if (R >= 0) ans = max(ans, solve(0, R, i));
  }
  cout << ans;
}
