#include <bits/stdc++.h>
using namespace std;
char _;
long long GCD(long long a, long long b) { return b == 0 ? a : GCD(b, a % b); }
long long i, j, k, a, b, c, d, f, g, h, l, m, n, p, q, r, s, t, u, v, w, x, y,
    z, maxx = INT_MIN, minn = INT_MAX, ans = 0, sum = 0, cnt = 0;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> n >> a >> b >> p >> q;
  x = (p * (n / a)) + (q * (n / b));
  y = (a * b) / GCD(a, b);
  z = min(p, q);
  cout << x - z * (n / y) << endl;
  return 0;
}
