#include <bits/stdc++.h> using namespace std; typedef long long ll; ll gcd(ll a,ll b){ if(a<b) swap(a,b); while(a%b!=0){ ll tmp=b; b=a%b; a=tmp; } return b; } ll lcd(ll a,ll b){ return a*b/gcd(a,b); } int main(){ ll n,a,b,c; cin>>n>>a>>b>>c; ll p=n/a+n/b+n/c+n/lcd(c,lcd(a,b)); ll m=n/lcd(a,b)+n/lcd(b,c)+n/lcd(c,a); cout<<p-m<<endl; return 0; }