#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  return (a ? gcd(b % a, a) : b);
}
long long int power(long long int a, long long int n) {
  long long int p = 1;
  while (n > 0) {
    if (n % 2) {
      p = p * a;
    }
    n >>= 1;
    a *= a;
  }
  return p;
}
long long int power(long long int a, long long int n, long long int mod) {
  long long int p = 1;
  while (n > 0) {
    if (n % 2) {
      p = p * a;
      p %= mod;
    }
    n >>= 1;
    a *= a;
    a %= mod;
  }
  return p % mod;
}
const int INF = 0x3f3f3f3f, MOD = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  long long int n, a, b, p, q;
  cin >> n >> a >> b >> p >> q;
  long long int lcm = (long long int)(a * b) / gcd(a, b);
  long long int total;
  if (p > q) {
    total = p * (n / a) + q * (n / b - n / lcm);
  } else {
    total = p * (n / a - n / lcm) + q * (n / b);
  }
  cout << total << endl;
}
