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