#include <bits/stdc++.h>
using namespace std;
long long cal(long long k, long long a, long long t, long long m) {
  long long haz = (t - k) / a + 1;
  long long res = 0;
  long long hidari = ((t - k) / a + 1) * a + k - t;
  hidari = min(hidari, m - t + 1);
  res += hidari * haz;
  long long owa = (m - k) / a + 1;
  long long migi = m - ((m - k) / a * a + k) + 1;
  if (haz == owa) {
    return res;
  }
  res += owa * migi;
  if ((haz + 1) == owa) {
    return res;
  }
  long long te = (owa - 1) * owa / 2 - haz * (haz + 1) / 2;
  te *= a;
  res += te;
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long m;
  int a, b;
  cin >> m >> a >> b;
  long long res = 0;
  vector<int> kai((a + b) * 2), memo(a);
  kai[0] = 1;
  memo[0] = 1;
  res += cal(0, a, 0, m);
  for (int i = 0; i < (a + b) * 2; i++) {
    if (i > m) break;
    if (i < a) continue;
    if (kai[i - a] == 0) continue;
    stack<int> st;
    st.push(i);
    kai[i] = 1;
    while (st.size()) {
      int cur = st.top();
      st.pop();
      if (memo[cur % a] == 0) {
        res += cal(cur % a, a, i, m);
        memo[cur % a] = 1;
      }
      if ((cur + a) <= i) {
        if (kai[cur + a] == 0) {
          st.push(cur + a);
          kai[cur + a] = 1;
        }
      }
      if ((cur - b) >= 0) {
        if (kai[cur - b] == 0) {
          st.push(cur - b);
          kai[cur - b] = 1;
        }
      }
    }
    if (i == m) break;
  }
  cout << res << "\n";
  return 0;
}
