#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long long n, a, b, p, q;
  cin >> n >> a >> b >> p >> q;
  long long someGcd = gcd(a, b);
  long long lcm = a * b / someGcd;
  long long max = (p > q) ? p : q;
  if (p > q) {
    long long counta = p * (n / a);
    long long countb = q * (n / b) - q * (n / lcm);
    cout << counta + countb;
  } else {
    long long counta = p * (n / a) - p * (n / lcm);
    long long countb = q * (n / b);
    cout << counta + countb;
  }
}
