#include <bits/stdc++.h>
const long long OO = LLONG_MAX;
const long long _OO = LLONG_MIN;
const long long MOD = 1e9 + 7;
const double PI = acos(-1);
const double EPSILON = std::numeric_limits<double>::epsilon();
bool double_comp(double a, double b) { return fabs(a - b) < EPSILON; }
unsigned long long gcd(unsigned long long a, unsigned long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
unsigned long long lcm(unsigned long long a, unsigned long long b) {
  return (a * b) / gcd(a, b);
}
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  unsigned long long n, a, b, p, q;
  cin >> n >> a >> b >> p >> q;
  unsigned long long common = n / lcm(a, b);
  unsigned long long res =
      ((n / a) - common) * p + ((n / b) - common) * q + common * max(p, q);
  cout << res;
}
