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