#include<bits/stdc++.h>
using namespace std;
#define int long long
int n, a, b, c, ans;
bool f[10000010];
signed main() {
freopen("burnTokyo.in", "r", stdin);
freopen("burnTokyo.out", "w", stdout);
cin >> n >> a >> b >> c;
f[1] = 1;
for(int i = 1; i <= n; i ++) {
if(f[i]) {
ans ++;
int x1 = i + a, x2 = i + b, x3 = i + c;
if(x1 <= n) {
f[x1] = 1;
}
if(x2 <= n) {
f[x2] = 1;
}
if(x3 <= n) {
f[x3] = 1;
}
}
}
cout << ans << endl;
return 0;
}