#include <bits/stdc++.h>
using namespace std;
long long GCD(long long x, long long y) {
  if (x < y) return GCD(y, x);
  if (y == 0) return x;
  return GCD(y, x % y);
}
long long LCM(long long x, long long y) { return (x / GCD(x, y)) * y; }
int main() {
  long long n, a, b, p, q;
  cin >> n >> a >> b >> p >> q;
  long long ca = n / a, cb = n / b, cab = n / LCM(a, b);
  cout << (ca - cab) * p + (cb - cab) * q + cab * max(p, q) << "\n";
  return 0;
}
