#include <bits/stdc++.h>
int main() {
  int n, a[3], dp[4002];
  memset(dp, 0, sizeof(dp));
  std::cin >> n >> a[0] >> a[1] >> a[2];
  std::sort(a, a + 3);
  for (int i = 0; i < 3; i++) {
    for (int j = n; j - a[i] >= 0; j--) {
      for (int k = 1; k <= j / a[i]; k++)
        if (j % a[i] == 0 || dp[j - a[i] * k] != 0)
          dp[j] = std::max(dp[j], dp[j - a[i] * k] + k);
    }
  }
  std::cout << dp[n];
  return 0;
}
