#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, c;
  cin >> n >> a >> b >> c;
  int res = -1;
  for (int i = 0; i <= 4000; i++)
    for (int j = 0; j <= 4000; j++) {
      if (n - i * a - j * b >= 0 && (n - i * a - j * b) % c == 0) {
        if (i + j + (n - i * a - j * b) / c > res)
          res = i + j + (n - i * a - j * b) / c;
      }
    }
  cout << res;
}
