#include <bits/stdc++.h>
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
const int N = 2e5 + 5;
bool vis[N];
int step[N], tot;
int main() {
  int m, a, b;
  scanf("%d%d%d", &m, &a, &b);
  const int g = gcd(a, b);
  long long ans = 1ll * (1 + m / g + 1) * (m / g + 1) / 2ll * g -
                  1ll * (1ll * (m / g + 1) * g - m - 1) * (m / g + 1);
  vis[step[++tot] = 0] = true;
  while (true) {
    ++tot;
    step[tot] = step[tot - 1] >= b ? step[tot - 1] - b : step[tot - 1] + a;
    if (vis[step[tot]]) break;
    vis[step[tot]] = true;
  }
  --tot;
  for (int i = 0, j = 1; i < a + b && i <= m; ++i) {
    ans -= i / g + 1;
    while (step[j] <= i && j <= tot) ++j;
    ans += j - 1;
  }
  printf("%lld", ans);
}
