#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a, b, p, q, maxx, max_cost, minn, min_cost, t, nok, a1, b1;
  cin >> n >> a >> b >> p >> q;
  if (p > q) {
    max_cost = p;
    maxx = a;
    minn = b;
    min_cost = q;
  } else {
    max_cost = q;
    maxx = b;
    minn = a;
    min_cost = p;
  }
  a1 = maxx;
  b1 = minn;
  while (b1 > 0) {
    t = b1;
    b1 = a1 % b1;
    a1 = t;
  }
  nok = a * b / a1;
  cout << ((n / maxx) * max_cost + (n / minn - n / nok) * min_cost);
  return 0;
}
