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