#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const int max_n = 70000 + 1;
long long n, a, b, p, q;
long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  if (a % b == 0) return b;
  return gcd(b, a % b);
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  cin >> n >> a >> b >> p >> q;
  long long lcm = (a * b) / gcd(a, b);
  long long cm = n / lcm;
  long long pa = n / a - cm;
  long long pb = n / b - cm;
  if (p > q)
    cout << p * (pa + cm) + q * pb;
  else
    cout << p * pa + (pb + cm) * q;
}
