#include <bits/stdc++.h>
using namespace std;
long long calc_gcd(long long x, long long y) {
  if (y == 0) return x;
  return calc_gcd(y, x % y);
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long M, A, B;
  cin >> M >> A >> B;
  vector<long long> step(A + B, -1);
  int cur = 0, tmp = 0;
  while (true) {
    step[cur] = tmp;
    if (cur >= B)
      cur -= B;
    else
      cur += A;
    if (cur == 0) break;
    tmp = max(tmp, cur);
  }
  long long ans = 0;
  for (int i = 0; i < A + B; i++) {
    if (step[i] != -1) ans += max(0LL, M + 1 - step[i]);
  }
  if (M > A + B - 1) {
    long long l = A + B, r = M;
    long long g = calc_gcd(A, B);
    while (l % g) l++;
    while (r % g) r--;
    long long dist = (r - l) / g;
    long long f = M - r + 1;
    ans += (2 * f + g * dist) * (dist + 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
