#include <bits/stdc++.h>
using namespace std;
inline int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
int q[200005];
bool vis[200005];
int main() {
  int m, a, b;
  cin >> m >> a >> b;
  int k = gcd(a, b);
  long long ans = (long long)(m / k + 1) * (m / k + 2) / 2 * k -
                  (long long)((m / k + 1) * k - m - 1) * (m / k + 1);
  for (int i = 0; i < a + b && i <= m; i++) ans -= i / k + 1;
  q[1] = 0;
  int c = 1;
  vis[0] = 1;
  while (true) {
    q[c + 1] = q[c] >= b ? q[c] - b : q[c] + a;
    c++;
    if (vis[q[c]])
      break;
    else
      vis[q[c]] = 1;
  }
  for (int i = 0, j = 1; i < a + b && i <= m; i++) {
    while (q[j] <= i && j < c) j++;
    ans += j - 1;
  }
  cout << ans;
  return 0;
}
