#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int main() {
  long long n, a, b, p, q;
  cin >> n >> a >> b >> p >> q;
  long long m1 = p * (n / a), m2 = q * (n / b);
  long long gcdd = a * b / gcd(a, b);
  long long pq = min(p, q);
  cout << m1 + m2 - pq * (n / gcdd) << endl;
}
