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