#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long solver(long long m, long long a, long long b) {
  vector<long long> v;
  v.push_back(0);
  long long currnum = a;
  v.push_back(currnum);
  long long g = gcd(a, b);
  while (v.size() != (a + b) / g) {
    while (currnum + a < a + b) {
      currnum += a;
      v.push_back(currnum);
    }
    while (currnum - b > 0) {
      currnum -= b;
      v.push_back(currnum);
    }
  }
  long long arr[(a + b) / g];
  arr[0] = 0;
  for (long long k = 1; k < (a + b) / g; k++) arr[k] = max(v[k], arr[k - 1]);
  long long summer[a + b];
  for (long long k = 0; k < a + b; k++) summer[k] = 0;
  for (long long k = 0; k < (a + b) / g; k++) summer[arr[k]]++;
  for (long long k = 1; k < a + b; k++) summer[k] += summer[k - 1];
  if (a + b > m) {
    long long ans = 0;
    for (long long k = 0; k <= m; k++) ans += summer[k];
    return ans;
  } else {
    long long tempans = 0;
    for (long long k = 0; k < a + b; k++) tempans += summer[k];
    long long num = m;
    long long num2 = (a + b);
    long long cap = num / g;
    cap *= g;
    cap -= g;
    long long numinside = (cap / g) - (num2 / g) + 1;
    long long tempans2 = (num2 + cap) * numinside / 2;
    long long adder = m / g;
    long long rem = (m - (cap + g) + 1);
    tempans2 += adder * rem;
    long long ans = tempans + tempans2;
    ans += (m - (a + b) + 1);
    return ans;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long m, a, b;
  cin >> m >> a >> b;
  long long ans = solver(m, a, b);
  cout << ans << endl;
}
