#include <bits/stdc++.h>
using namespace std;
long long x, y;
long long gcd(long long x, long long y) {
  if (y > x) swap(x, y);
  while (y != 0) {
    long long tmp = x % y;
    x = y;
    y = tmp;
  }
  return x;
}
int main() {
  long long int n, a, b, p, q, ans, c, l, t, s, r;
  while (scanf("%lld %lld %lld %lld %lld", &n, &a, &b, &p, &q) != EOF) {
    l = (a * b) / gcd(a, b);
    x = (n / a);
    y = (n / b);
    c = (n / l);
    x -= c;
    y -= c;
    ans = x * p + y * q;
    if (p > q) {
      ans += c * p;
    } else {
      ans += c * q;
    }
    printf("%lld\n", ans);
  }
  return 0;
}
