#include <bits/stdc++.h>
using namespace std;
long long m, a, b;
long long ans = 0;
long long ha[200100];
long long k[200100];
long long r[200100][2];
long long p[200100];
long long sans = 0;
long long gcd(long long a, long long b) {
  if (a < b) {
    long long t;
    t = a;
    a = b;
    b = t;
  }
  if (a % b == 0) return b;
  return gcd(b, a % b);
}
int main() {
  scanf("%lld%lld%lld", &m, &a, &b);
  long long d = gcd(a, b);
  long long a1 = a / d;
  long long b1 = b / d;
  long long i = 0;
  long long t = 0;
  k[0] = 0;
  while (ha[i] == 0) {
    k[t] = i;
    t++;
    ha[i] = 1;
    if (i - b >= 0)
      i = i - b;
    else
      i = i + a;
  }
  long long ma = 0;
  long long tt = 0;
  for (long long i = 0; i < a1 + b1; i++) {
    if (k[i] >= ma) {
      if (k[i] == (a1 + b1 - 1) * d) {
        r[tt][0] = k[i];
        r[tt][1] = i;
      } else {
        r[tt][0] = k[i];
        r[tt][1] = i;
      }
      ma = k[i];
      tt++;
    }
  }
  r[tt][1] = (a1 + b1 - 1) * d;
  for (long long i = 0; i < tt - 1; i++)
    for (long long j = r[i][0]; j < r[i + 1][0]; j++) p[j] = r[i + 1][1];
  for (long long i = (a1 + b1 - 1) * d; i < (a1 + b1) * d; i++) p[i] = a1 + b1;
  if (m < (a1 + b1) * d) {
    for (long long i = 0; i <= m; i++) ans += p[i];
    printf("%lld", ans);
    return 0;
  }
  for (long long i = 0; i < (a1 + b1) * d; i++) ans += p[i];
  long long m1 = m / d;
  ans += (a1 + b1 + 1 + m1) * (m1 - a1 - b1) / 2 * d;
  ans += (m1 + 1) * (m + 1 - m1 * d);
  printf("%lld", ans);
  return 0;
}
