#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, a, b, p, q, ans;
  cin >> n >> a >> b >> p >> q;
  long long int x1 = n / a;
  long long int x2 = n / b;
  long long int x = min(a, b);
  long long int y = max(a, b);
  long long int z = n + 5;
  int count = 0;
  for (int i = y; i <= n; i += y) {
    if (i % x == 0) {
      count++;
      z = i;
      break;
    }
  }
  count = (n / z);
  if (p > q)
    ans = (x1 * p) + ((x2 - count) * q);
  else
    ans = ((x1 - count) * p) + (x2 * q);
  cout << ans << endl;
}
