#include <bits/stdc++.h>
using namespace std;
long long ans, m, a, b, d, check[200005], s[200005], cnt;
long long gcd(long long x, long long y) { return y == 0 ? x : gcd(y, x % y); }
int main() {
  cin >> m >> a >> b;
  d = gcd(a, b);
  ans = (m / d + 1) * (m / d) * d / 2 + (m % d + 1) * (m / d + 1);
  for (cnt = 0; !check[s[cnt]];) {
    check[s[cnt++]] = 1;
    s[cnt] = s[cnt - 1] >= b ? s[cnt - 1] - b : s[cnt - 1] + a;
  }
  for (int i = 0, tot = 0; i < a + b && i <= m; i++) {
    ans -= i / d + 1;
    while (tot < cnt && s[tot] <= i) tot++;
    ans += tot;
  }
  cout << ans << endl;
}
