#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a % b == 0) return b;
  return gcd(b, a % b);
}
bool used[300000];
int main() {
  long long m, a, b;
  cin >> m >> a >> b;
  int g = gcd(a, b);
  long long cnt = 1, sum = 0;
  used[0] = true;
  for (int i = 0; i <= min(m, a + b - g); i++) {
    if (i < a) {
      sum += cnt;
      continue;
    }
    if (!used[i - a]) {
      sum += cnt;
      continue;
    }
    deque<int> que;
    que.push_back(i);
    while (!que.empty()) {
      int pos = que.front();
      que.pop_front();
      if (used[pos]) continue;
      used[pos] = true;
      cnt++;
      if (pos >= b && !used[pos - b]) que.push_back(pos - b);
      if (pos + a <= i && !used[pos + a]) que.push_back(pos + a);
    }
    sum += cnt;
  }
  if (m <= a + b - g) {
    cout << sum << endl;
    return 0;
  }
  if (m - (a + b - g) < g) {
    cout << sum + cnt * (m - (a + b - g)) << endl;
    return 0;
  }
  sum += cnt * (g - 1);
  long long k = (m - (a + b - 1)) / g;
  sum += (k * cnt + k * (k + 1) / 2) * g;
  long long res = m - (a + b - 1) - g * k;
  sum += res * (cnt + k + 1);
  cout << sum << endl;
  return 0;
}
