#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 7;
const long long mod = 1e9 + 7;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
map<long long, long long> mp;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long i = 1;
  vector<long long> v;
  long long n, a, b, m;
  cin >> m >> a >> b;
  long long k = gcd(a, b);
  long long z = m / k;
  long long val1 = m * z - (k * z * (z + 1) / 2) + z + m + 1;
  long long val2 = 0;
  long long start = 0;
  long long cnt = 0;
  long long ans = 0;
  long long currmx = 0;
  while (start <= (a + b)) {
    if (mp[start]) break;
    mp[start] = 1;
    currmx = max(currmx, start);
    if (start <= m) {
      ans += min(currmx - start, m - start + 1);
    }
    if (start >= b)
      start -= b;
    else
      start += a;
  }
  cout << val1 - ans << "\n";
  return 0;
}
