#include <bits/stdc++.h>
using namespace std;
int m, a, b, g, Min;
void exgcd(int a, int b, int& g, int& x, int& y) {
  if (b == 0) {
    x = 1;
    y = 0;
    g = a;
  } else {
    exgcd(b, a % b, g, y, x);
    y -= x * (a / b);
  }
}
int getMin(int x, int y) {
  while (x <= 0) x += b / g, y -= a / g;
  int cur = 0, ret = 0;
  while (x || y) {
    if (cur > b && y < 0) {
      int d = min(cur / b, -y);
      y += d;
      cur -= d * b;
    } else if (x > 0)
      cur += a, x--;
    ret = max(ret, cur);
  }
  return ret;
}
struct node {
  int x, d;
  bool operator<(const struct node& b) const { return d > b.d; }
};
priority_queue<node> q;
int dis[400005];
void bfs() {
  for (int i = 1; i <= 2 * Min; i++) dis[i] = 0x3f3f3f3f;
  dis[0] = 0;
  q.push(node{0, 0});
  while (!q.empty()) {
    node tmp = q.top();
    q.pop();
    if (tmp.d > dis[tmp.x]) continue;
    dis[tmp.x] = tmp.d;
    if (tmp.x - b >= 0 && dis[tmp.x - b] > tmp.d)
      dis[tmp.x - b] = tmp.d, q.push(node{tmp.x - b, tmp.d});
    if (tmp.x + a <= 2 * Min && dis[tmp.x + a] > max(tmp.d, tmp.x + a))
      dis[tmp.x + a] = max(tmp.d, tmp.x + a),
                  q.push(node{tmp.x + a, max(tmp.d, tmp.x + a)});
  }
}
int main() {
  int x, y;
  cin >> m >> a >> b;
  exgcd(a, b, g, x, y);
  Min = getMin(x, y);
  bfs();
  long long ans = 0;
  for (int i = 0; i <= Min && i <= m; i++) ans += max(0, m - dis[i] + 1);
  if (m <= Min)
    printf("%lld", ans);
  else {
    int k = (m - Min) / g;
    ans += (long long)(m - Min + 1) * k - (long long)g * (1 + k) * k / 2;
    printf("%lld\n", ans);
  }
  return 0;
}
