#include<stdio.h>
#include<algorithm>
using namespace std;
long long gcd(long long a,long long b){
	while(a){
		b%=a;long long c=a;a=b;b=c;
	}
	return b;
}
long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}
int main(){
	long long n,a,b,c;
	scanf("%lld%lld%lld%lld",&n,&a,&b,&c);
	printf("%lld\n",n/a+n/b+n/c-n/lcm(a,b)-n/lcm(b,c)-n/lcm(a,c)+n/lcm(a,lcm(b,c)));
}