#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int arr[3];
  cin >> n >> arr[0] >> arr[1] >> arr[2];
  sort(arr, arr + 3);
  int counter = 0;
  if (n % arr[0] == 0) {
    while (n > 0) {
      counter++;
      n -= arr[0];
    }
    cout << counter;
  } else {
    long long c_size = 0;
    int ma = 0;
    for (int i = 1; i < 1000; i++) {
      c_size += i * arr[1];
      if (c_size > n) {
        break;
      }
      if ((n - c_size) % arr[0] == 0) {
        counter = i + ((n - c_size) / arr[0]);
        ma = max(ma, counter);
      } else {
        c_size = 0;
        counter = 0;
      }
    }
    for (int i = 0; i < 1000; i++) {
      for (int j = 0; j < 1000; j++) {
        c_size = arr[0] * i + arr[1] * j;
        if (c_size > n) {
          break;
        }
        c_size = n - c_size;
        if (c_size % arr[2] == 0) {
          counter = (i + j + (c_size / arr[2]));
        }
        ma = max(ma, counter);
      }
    }
    cout << ma;
  }
  return 0;
}
