#include <bits/stdc++.h>
long long gcd(long long u, long long v) {
  long long t;
  while (v) {
    t = u;
    u = v;
    v = t % v;
  }
  if (u < 0) u = 0 - u;
  return u;
}
long long lcm(long long u, long long v) { return (u * v) / gcd(u, v); }
int main() {
  int i, j, k;
  long long n, a, b, p, q, x, y, z, res;
  while (scanf("%lld %lld %lld %lld %lld", &n, &a, &b, &p, &q) != EOF) {
    x = n / a, y = n / b, z = n / lcm(a, b);
    res = p * (x - z) + q * (y - z);
    if (p > q)
      res += (p * z);
    else
      res += (q * z);
    printf("%lld\n", res);
  }
  return 0;
}
