#include <bits/stdc++.h>
using namespace std;
unsigned long long gcd(unsigned long long a, unsigned long long b) {
  if (!b) {
    return a;
  }
  return gcd(b, a % b);
}
unsigned long long lcm(unsigned long long a, unsigned long long b) {
  return (a * b) / gcd(a, b);
}
int main() {
  unsigned long long n, a, b, p, q;
  while (cin >> n >> a >> b >> p >> q) {
    unsigned long long tmp1 = n / a;
    unsigned long long tmp2 = n / b;
    unsigned long long tmp3 = (n / lcm(a, b));
    if (a == b) {
      cout << tmp1 * max(p, q) << endl;
    } else if (p >= q) {
      cout << (tmp1 * p) + ((tmp2 - tmp3) * q) << endl;
    } else {
      cout << (tmp2 * q) + ((tmp1 - tmp3) * p) << endl;
    }
  }
  return 0;
}
