#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  vector<int> l(3);
  int c1 = 0;
  int c2 = 0;
  int c3 = 0;
  int c4 = 0;
  int n;
  cin >> n >> l[0] >> l[1] >> l[2];
  int c;
  int r = n;
  sort(l.begin(), l.end());
  while (n % l[0]) {
    c = n;
    while (c > 0) {
      c -= l[1];
      c1++;
      if (!(c % l[0])) break;
    }
    if (c >= 0) break;
    n -= l[2];
    c1 = 0;
    c2++;
  }
  n = r;
  while (n % l[0]) {
    c = n;
    while (c > 0) {
      c -= l[2];
      c3++;
      if (!(c % l[0])) break;
    }
    if (c >= 0) break;
    n -= l[1];
    c3 = 0;
    c4++;
  }
  if (c1 + c2 + (r - c1 * l[1] - c2 * l[2]) / l[0] >
      c3 + c4 + (r - c4 * l[1] - c3 * l[2]) / l[0]) {
    cout << c1 + c2 + (r - c1 * l[1] - c2 * l[2]) / l[0];
  } else
    cout << c3 + c4 + (r - c4 * l[1] - c3 * l[2]) / l[0];
}
