#include <bits/stdc++.h>
using namespace std;
long long int hcf(long long int n1, long long int n2) {
  if (n2 != 0)
    return hcf(n2, n1 % n2);
  else
    return n1;
}
int main() {
  long long int a, b, c, d, e, i, j, k, x, y, z, p, q, ans, ans1;
  cin >> a >> b >> c >> d >> e;
  p = hcf(b, c);
  p = (b * c) / p;
  x = a / b;
  y = a / c;
  z = a / p;
  ans = (x - z) * d + (y)*e;
  ans1 = (x)*d + (y - z) * e;
  ans = max(ans, ans1);
  cout << ans;
  return 0;
}
