#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 500;
int gti(void) {
  char c = getchar();
  int ret = 0, st = 1;
  for (; !isdigit(c); c = getchar())
    if (c == '-') st = -1;
  for (; isdigit(c); c = getchar()) ret = ret * 10 + c - '0';
  return ret * st;
}
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
bool vis[N << 1], fr[N];
long long tot, ans;
int m, a, b;
void search(int val, int i) {
  if (vis[val]) return;
  vis[val] = true, ++tot;
  fr[val % a] = true;
  if (val - b >= 0) search(val - b, i);
  if (val + a <= i) search(val + a, i);
}
int main(void) {
  m = gti(), a = gti(), b = gti();
  fr[0] = true;
  for (int i = 0; i < a + b && i <= m; i++) {
    if (fr[i % a]) search(i, i);
    ans += tot;
  }
  if (a + b <= m) {
    int c = gcd(a, b);
    ans += 1ll * ((a + b) / c + m / c + 1) * (m / c - (a + b) / c) / 2 * c;
    ans += (m % c + 1) * (m / c + 1);
  }
  printf("%lld\n", ans);
  return 0;
}
