#include <iostream>
using namespace std;
int main() {
    int n, a, b, c; cin >> n >> a >> b >> c;
    if (a == 1 or b == 1 or c == 1) {
        cout << n << endl;
        return 0;
    }
    int i = n % a, j = n % b, k = n % c;
    int ans = 0;
    while (true) {
        int d = min(i, min(j, k));
        i -= d; if (i == 0) i = a;
        j -= d; if (j == 0) j = b;
        k -= d; if (k == 0) k = c;
        n -= d; if (n <= 0) break;
        ++ ans;
    }
    cout << ans << endl;
    return 0;
}