#include <bits/stdc++.h>
using namespace std;
const long long INF64 = 1000000000000000000;
const long long BigPrime = 252097800623;
const long double LDINF = 1000000000000;
const long long Mmod = 998244353;
const long long INF = 1000000000;
const long long Mod = 1000000007;
const long double PI = acosl(-1.);
const long double Eps = 10e-10;
const long long Prime = 31;
const unsigned int N = 100005;
long long m, a, b;
long long hgh[1000000];
bool visited[1000000];
priority_queue<int> pq;
long long gcd(long long a, long long b) { return (a == 0 ? b : gcd(b % a, a)); }
void input() { cin >> m >> a >> b; }
void solve() {
  pq.push(0);
  for (int i = 0; i <= 400000; i++) hgh[i] = i;
  visited[0] = true;
  vector<int> test;
  while (!pq.empty()) {
    int cd = -pq.top();
    pq.pop();
    test.push_back(cd);
    if (cd > b && !visited[cd - b]) {
      visited[cd - b] = true;
      hgh[cd - b] = max(hgh[cd], hgh[cd - b]);
      pq.push(b - cd);
    }
    if (cd + a <= 400000 && !visited[cd + a]) {
      visited[cd + a] = true;
      hgh[cd + a] = max(hgh[cd], hgh[cd + a]);
      pq.push(-(cd + a));
    }
  }
  if (m <= 400000) {
    long long ans = 0;
    for (int i = 0; i <= m; i++)
      if (hgh[i] <= m && visited[i]) ans += (m - hgh[i] + 1);
    cout << ans << endl;
  } else {
    long long ans = 0;
    for (int i = 0; i <= 400000; i++)
      if (visited[i]) ans += (m - hgh[i] + 1);
    long long d = gcd(a, b);
    long long from = 400000 / d + 1, to = m / d;
    ans += (to - from + 1) * (m + 1) -
           d * ((to * (to + 1) / 2) - (from * (from - 1) / 2));
    cout << ans << endl;
  }
}
int main() {
  int testcases = 1;
  for (int _ = 0; _ < testcases; ++_) {
    input();
    solve();
  }
  return 0;
}
