import math N = int(input()) a,b,c = map(int,input().split()) x = a * b // math.gcd(a,b) y = b * c // math.gcd(b,c) z = c * a // math.gcd(c,a) p = x * y // math.gcd(x,y) ans = N // a + N // b + N // c - N // x - N // y - N // z + N // p print (ans)