#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
int main() {
  long long n, a, b, p, q;
  while (cin >> n >> a >> b >> p >> q) {
    long long cmt = a / gcd(a, b) * b;
    long long minx = min(p, q);
    long long sum;
    sum = n / a * p + n / b * q - minx * (n / cmt);
    cout << sum << endl;
  }
  return 0;
}
