#include <bits/stdc++.h>
using namespace std;
long long gcd(int a, int b) {
  while (b ^= a ^= b ^= a %= b)
    ;
  return a;
}
int main(void) {
  long long n, a, b, p, q;
  cin >> n >> a >> b >> p >> q;
  long long s = n / a;
  long long m = n / b;
  long long f = a * b / gcd(a, b);
  long long ff = (n / f);
  if (p < q)
    cout << (s - ff) * p + m * q << endl;
  else
    cout << s * p + (m - ff) * q << endl;
}
