#include <bits/stdc++.h>
using namespace std;
int gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int main() {
  long long n, a, b, p, q, t;
  cin >> n >> a >> b >> p >> q;
  t = a / gcd(a, b) * b;
  long long x = n / a, y = n / b, z = n / t;
  if (p >= q)
    cout << p * x + q * (y - z) << endl;
  else
    cout << p * (x - z) + q * y << endl;
}
