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