#include <bits/stdc++.h>
const int maxn = 1e5 + 20;
int x[maxn * 2];
int m, a, b;
void dfs(int cur, int val) {
  if (x[cur] == -1) {
    val = std::max(cur, val);
    x[cur] = val;
    if (cur >= b) {
      dfs(cur - b, val);
    } else {
      dfs(cur + a, val);
    }
  }
}
int main() {
  std::cin >> m >> a >> b;
  memset(x, -1, sizeof(x));
  dfs(0, 0);
  long long ans = 0;
  for (int i = 0; i < a; i++) {
    if (x[i] != -1) {
      if (x[i] <= m) {
        int k1 = (m - i) / a;
        int k2 = (x[i] - i) / a;
        int first = m - ((k2 + 1) * a + i) + 1;
        int last = m - (k1 * a + i) + 1;
        ans += 1ll * (m - x[i] + 1) * (k2 + 1);
        ans += 1ll * (first + last) * (k1 - k2) / 2;
      }
    }
  }
  std::cout << ans;
  return 0;
}
