#include <bits/stdc++.h>
using namespace std;
int in() {
  int x;
  scanf("%d", &x);
  return x;
}
long long lin() {
  long long x;
  scanf("%lld", &x);
  return x;
}
long long MOD = 998244353;
int main() {
  long long m = in(), a = in(), b = in();
  long long t[210000] = {};
  long long now = 0;
  t[0] = 1;
  long long l = 0;
  int times = b;
  while (times--) {
    while (now < b) {
      now += a;
      l = max(l, now);
      if (t[now])
        t[now] = min(t[now], l);
      else
        t[now] = l;
    }
    l = max(l, now);
    if (now > m) break;
    while (now - b >= 0) {
      now -= b;
      if (t[now]) {
        t[now] = min(t[now], l);
      } else
        t[now] = l;
    }
  }
  long long ans = 0;
  for (long long i = 0; i < a; i++) {
    if (t[i]) {
      now = i;
      if (i == 0) t[i] = 0;
      while (now < t[i]) {
        ans += m - t[i] + 1;
        now += a;
      }
      if (now > m) continue;
      long long n = (m - now + 1) / a + 1;
      ans += (m - now + 1 + (m - now + 1) % a) * n / 2;
    }
  }
  cout << ans;
}
