#include <bits/stdc++.h>
using namespace std;
bool used[500005];
int f = 1;
int a, b;
void dfs(int u, int bd) {
  used[u] = true;
  ++f;
  if (u - b >= 0 && !used[u - b]) {
    dfs(u - b, bd);
  }
  if (u + a <= bd && !used[u + a]) {
    dfs(u + a, bd);
  }
}
int main() {
  used[0] = true;
  int m;
  cin >> m >> a >> b;
  long long res = 0;
  const int M = 500000;
  for (int i = 0; i <= min(m, M); ++i) {
    if (i - a >= 0 && used[i - a]) dfs(i, i);
    res += f;
  }
  if (m > M) {
    res += (long long)(f) * (m - M);
    int rem;
    for (rem = 0; rem < a; ++rem) {
      if (!used[rem]) continue;
      long long l = M / a * a + rem;
      if (l <= M) l += a;
      long long r = m / a * a + rem;
      if (r > m) r -= a;
      if (l <= r) {
        long long cnt = (r - l) / a + 1;
        res += cnt * (m - r + 1);
        res += a * cnt * (cnt - 1) / 2;
      }
    }
  }
  cout << res << '\n';
}
