#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)2e5 + 100;
int vis[maxn], step[maxn], pos = 0;
long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }
int main() {
  long long m, a, b;
  cin >> m >> a >> b;
  const long long g = gcd(a, b);
  long long last = m / g + 1;
  long long ans = (1 + last) * last / 2 * g - (last * g - 1 - m) * last;
  vis[step[++pos] = 0] = 1;
  while (1) {
    ++pos;
    step[pos] = step[pos - 1] >= b ? step[pos - 1] - b : step[pos - 1] + a;
    if (vis[step[pos]]) break;
    vis[step[pos]] = 1;
  }
  --pos;
  for (int i = 0, j = 1; i < a + b && i <= m; ++i) {
    ans -= i / g + 1;
    while (step[j] <= i && j <= pos) ++j;
    --j;
    ans += j;
  }
  cout << ans << endl;
}
