#include <bits/stdc++.h>
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF = 0x3f3f3f3f3f3f3f3f;
void accelerate() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
long long m, a, b;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long sum(long long n) {
  if (n <= 0) return 0;
  long long cnt = n / a;
  long long rem = n - cnt * a + 1;
  long long ans = cnt * (cnt - 1) / 2 * a;
  ans += cnt * rem;
  return ans;
}
int main() {
  accelerate();
  cin >> m >> a >> b;
  long long ans = 0;
  vector<long long> X(a, -1);
  long long x = 0;
  long long cur = 0;
  vector<int> vis(a + b + 1);
  while (!vis[cur]) {
    vis[cur] = 1;
    if (cur < a) {
      X[cur] = x;
    }
    if (cur >= b) {
      cur -= b;
    } else {
      cur += a;
      x = max(cur, x);
    }
  }
  for (long long i = 0; i < a; ++i) {
    if (X[i] == -1) continue;
    if (m < X[i]) continue;
    ans += m - X[i] + 1;
    ans += sum(m - i) - sum(X[i] - i - 1);
  }
  cout << ans << endl;
}
