#include typedef long long ll; using namespace std; template T gcd(T a, T b) { while (a) { b %= a; swap(a, b); } return b; } template T lcm(T a, T b) { return (a * b) / gcd(a,b); } int main() { int n, a, b, c; cin >> n >> a >> b >> c; ll l = lcm(a, lcm(b, c)); int ans = 0; int x = -1; if (n/l) for (int i = 0; i < l+1; i += min(a-i%a, min(b-i%b, c-i%c))) ++ x; int y = -1; for (int i = 0; i < n%l+1; i += min(a-i%a, min(b-i%b, c-i%c))) ++ y; cout << (n/l)*x + y << endl; return 0; }