#include <bits/stdc++.h>
using namespace std;
int n, a, b, p, q, red, blue, both;
long long ans;
long long GCD(long long a, long long b) { return b ? GCD(b, a % b) : a; }
long long LCM(long long a, long long b) { return a / GCD(a, b) * b; }
int main() {
  scanf("%d%d%d%d%d", &n, &a, &b, &p, &q);
  both = n / LCM(a, b);
  red = n / a - both, blue = n / b - both;
  printf("%I64d\n", 1ll * red * p + 1ll * blue * q + 1ll * both * max(p, q));
  return 0;
}
