#include <bits/stdc++.h>
using namespace std;
long long getLCM(int a, int b) {
  int copyA = a, copyB = b;
  int r = a % b;
  while (r) {
    a = b;
    b = r;
    r = a % b;
  }
  int gcd = b;
  return 1LL * copyA * copyB / gcd;
}
int main() {
  int n, a, b, p, q;
  cin >> n >> a >> b >> p >> q;
  int divA = n / a;
  int divB = n / b;
  int divAB = n / getLCM(a, b);
  divA -= divAB;
  divB -= divAB;
  cout << 1LL * divA * p + 1LL * divB * q + 1LL * divAB * max(p, q);
  return 0;
}
