#include <bits/stdc++.h>
const int C = 2 * 100001;
int dp[C];
long long csc[C];
int main() {
  long long n, a, v = 0, gcd = 1000000, mx = 0, b, summa = 0, w1, w2, art = 0,
                  a1, an, t, s, sp, ep, ep2, m;
  int i = 0, j = 0;
  scanf("%lld %lld %lld", &n, &a, &b);
  v = a;
  while (dp[v] == 0 && v > 0) {
    if (gcd > v && v > 0) gcd = v;
    if (mx < v) mx = v;
    dp[v] = mx;
    if (v >= b)
      v -= b;
    else
      v += a;
  }
  for (i = 1; i < a + b; i++)
    if (dp[i] != 0) csc[dp[i]] += 1;
  csc[0]++;
  summa += csc[0];
  for (i = 1; i < a + b && i <= n; i++) {
    csc[i] += csc[i - 1];
    summa += csc[i];
  }
  s = (a + b) / gcd;
  sp = (s + 1) * gcd;
  if (sp > n) sp = n + 1;
  w1 = (sp - (a + b)) * (s + 1);
  t = n / gcd;
  ep = (t - 1) * gcd;
  ep2 = t * gcd;
  w2 = (n - ep2 + 1) * (t + 1);
  a1 = s + 1 + 1;
  an = t - 1 + 1;
  m = an - a1 + 1;
  if (m > 0)
    art = (((a1 + an) * m) / 2) * gcd;
  else
    art = 0;
  if (n >= a + b) {
    summa += w1 + art;
    if (s < t) summa += w2;
  }
  printf("%lld\n", summa);
  return 0;
}
