#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y) {
  if (x > y) swap(x, y);
  if (x <= 0) return y;
  if (y % x == 0) return x;
  return gcd(y % x, x);
}
int main() {
  vector<long long> a;
  long long b[400000];
  bool c[400000];
  for (long long i = 0; i < (long long)(400000); i++) {
    b[i] = 0;
    c[i] = false;
  }
  int n, k;
  long long g;
  long long x, y, z, xx, yy, zz;
  long long s, ans;
  bool v = true;
  ans = 0;
  scanf("%I64d %I64d %I64d", &z, &x, &y);
  g = gcd(x, y);
  a.push_back(0);
  c[0] = true;
  xx = 0;
  while (true) {
    if (xx >= y)
      xx -= y;
    else
      xx += x;
    if (c[xx])
      break;
    else
      c[xx] = true;
    a.push_back(xx);
  }
  xx = 0;
  yy = 0;
  zz = 0;
  while (true) {
    if (xx < a[yy]) {
      b[xx] = yy;
      zz = max(zz, yy);
      xx++;
    } else
      yy++;
    if (yy >= a.size()) break;
  }
  ans = 0;
  if (z < (x + y - g)) {
    for (long long i = 0; i < (long long)(z + 1); i++) ans += b[i];
    printf("%I64d\n", ans);
    return 0;
  }
  for (long long i = 0; i < (long long)(x + y - g); i++) {
    ans += b[i];
  }
  xx = (x + y) / g;
  yy = z / g;
  zz = (xx + yy) * (yy - xx + 1) / 2;
  zz *= g;
  ans += zz;
  zz = (z % g) + 1;
  zz *= ((z / g) + 1);
  ans += zz;
  printf("%I64d\n", ans);
  return 0;
}
