#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int s, a, b, c, e = 0, f = 0, g = 0, d = 0, h = 0, r = 0;
  cin >> s >> a >> b >> c;
  for (int i = 0; i <= s; i++) {
    for (int j = 0; j <= s; j++) {
      g = (i * a) + (j * b);
      if (s >= g && (s - g) % c == 0) {
        h = (s - g) / c;
        r = max(r, i + j + h);
      }
    }
  }
  cout << r << endl;
}
