#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (a == 0) {
    return b;
  } else {
    return gcd(b % a, a);
  }
}
int main() {
  int n, a, b, p, q;
  scanf("%d%d%d%d%d", &n, &a, &b, &p, &q);
  long long ans, ans1, ans2, ans3, k, l, h;
  h = gcd(a, b);
  k = b / h;
  k = a * k;
  l = min(p, q);
  ans1 = n / a;
  ans2 = n / b;
  ans3 = n / k;
  ans = ans1 * p + ans2 * q - ans3 * l;
  cout << ans << endl;
  return 0;
}
