#include <bits/stdc++.h>
using namespace std;
int main() {
  long long i, j, a, b, c, cnt, cn, n, k;
  while (cin >> n >> a >> b >> c) {
    long long ans = -1;
    for (long long i = 0; i < n + 1; i++)
      for (long long j = 0; j < n + 1; j++) {
        k = n - (a * i + b * j);
        if (k >= 0 && k % c == 0) ans = max(ans, (i + j + k / c));
      }
    printf("%lld\n", ans);
  }
  return 0;
}
