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