#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const int INF = INT_MAX;
const int MAX_N = 50005;
template <typename T>
inline T sqr(T a) {
  return a * a;
};
template <typename T>
T gcd(T a, T b) {
  return (b) ? gcd(b, a % b) : a;
}
template <typename T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
int main(int argc, char const *argv[]) {
  long long n, a, b, p, q;
  cin >> n >> a >> b >> p >> q;
  if (p > q)
    cout << (n / a) * p + (n / b - n / lcm(a, b)) * q << endl;
  else
    cout << (n / b) * q + (n / a - n / lcm(a, b)) * p << endl;
  return 0;
}
