#include <bits/stdc++.h>
using namespace std;
long long n, a, b, p, q;
long long aa, bb;
long long a1, a2, a3, lm;
long long ans;
int main() {
  cin >> n >> a >> b >> p >> q;
  aa = a;
  bb = b;
  while (true) {
    if (aa == 0) {
      lm = bb;
      break;
    }
    bb %= aa;
    if (bb == 0) {
      lm = aa;
      break;
    }
    aa %= bb;
  }
  lm = a / lm * b;
  ans += (n / a) * p;
  ans += (n / b) * q;
  ans -= (n / lm) * min(p, q);
  cout << ans;
  return 0;
}
