#include <bits/stdc++.h>
using namespace std;
int GCD(int a, int b) {
  if (b == 0)
    return a;
  else
    return GCD(b, a % b);
}
int main() {
  long long n, a, b, p, q, ans, LCM;
  cin >> n >> a >> b >> p >> q;
  LCM = (a * b) / GCD(a, b);
  long long m = max(a, b);
  long long mi = min(a, b), aa = n / a, bb = n / b;
  long long com = n / LCM;
  if (com * p < com * q) {
    aa -= com;
  } else
    bb -= com;
  ans = aa * p + bb * q;
  cout << ans;
  return 0;
}
