#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  long long n, a, b, p, q;
  scanf("%lld %lld %lld %lld %lld", &n, &a, &b, &p, &q);
  long long ans3 = (a * b) / gcd(a, b);
  long long ans = n / a;
  long long ans1 = n / b;
  long long ans2 = n / ans3;
  ans -= ans2;
  ans1 -= ans2;
  if (p > q)
    ans2 *= p;
  else
    ans2 *= q;
  ans = ans * p + ans1 * q + ans2;
  printf("%lld\n", ans);
  return 0;
}
