#include<bits/stdc++.h>
using namespace std;
long long int d[100001];
queue <long long int> q;
long long int h;
int x[3];
void bfs(long long int p){
d[p%x[0]]=min(d[p%x[0]],p);
if(d[p%x[0]]!=p){
return;
}
if(p>=h||p<0){
return;
}
if(d[(p+x[1])%x[0]]>p){
q.push(p+x[1]);
}
if(d[(p+x[2])%x[0]]>p){
q.push(p+x[2]);
}
}
int main(){
scanf("%lld",&h);
h--;
scanf("%d%d%d",&x[0],&x[1],&x[2]);
sort(x,x+3);
for(int i=1;i<=x[0];i++){
d[i]=1e18;
}
q.push(0);
while(!q.empty()){
bfs(q.front());
q.pop();
}
long long ans;
for(int i=0;i<x[0];i++){
if(d[i]<=h){
ans+=(h-d[i])/x[0]+1;
}
}
printf("%lld",ans-1);
return 0;
}