#include <bits/stdc++.h>
using namespace std;
long long n, a, b, p, q;
long long ans = 0;
long long gcd(long long x, long long y) { return y == 0 ? x : gcd(y, x % y); }
long long lcm(long long x, long long y) { return x * y / gcd(x, y); }
int main() {
  cin >> n >> a >> b >> p >> q;
  long long n1, m1, mm;
  n1 = n / a;
  m1 = n / b;
  mm = n / lcm(a, b);
  if (p > q) {
    ans = n1 * p + q * (m1 - mm);
  } else {
    ans = (n1 - mm) * p + q * m1;
  }
  cout << ans << endl;
  return 0;
}
