#include <bits/stdc++.h>
long long int gcd(long long int a, long long int b) {
  long long int x = a;
  while (a) {
    x = a;
    a = b % a;
    b = x;
  }
  return b;
}
long long int lcm(long long int a, long long int b) {
  return (a * b) / gcd(a, b);
}
int main() {
  long long int a, b, c, d, e;
  int cnt = 0;
  scanf("%lld%lld%lld%lld%lld", &a, &b, &c, &d, &e);
  long long int res = 0;
  long long int res1 = 0;
  res = ((a / b) * d) + (abs((a / c) - a / lcm(b, c)) * e);
  res1 = ((a / c) * e) + (abs((a / b) - a / lcm(b, c)) * d);
  res > res1 ? printf("%lld  ", res) : printf("%lld", res1);
}
