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