#include<iostream>
#include<algorithm>
#include<cstdint>
#include<map>
#include<vector>

int const MAXN = 2e5;
int64_t N, X, D;
typedef std::vector<std::pair<int64_t, int64_t>> IA;

int64_t calc() {
  int64_t res;
  if(D == 0) {
    if(X == 0) return 1;
    return N+1;
  }
  if(D < 0) { D = -D; X = -X; }
  std::map<int64_t, IA> m;
  for(int64_t k = 0; k <= N; ++k) {
    // S = kX + jD where j in [k(k-1)/2, k(2N-1-k)/2+1)
    int64_t rem = (k*X%D+D)%D;
    int64_t l = k*X/D + k*(k-1)/2;
    int64_t r = k*X/D + k*(N+N-k-1)/2 + 1;
    m[rem].emplace_back(l, r);
  }
  int64_t ans = 0;
  for(auto ia: m) {
    IA& v = ia.second;
    std::sort(v.begin(), v.end());
    int64_t last = -1e18;
    for(auto inter: v) {
      if(inter.second <= last) continue;
      ans += inter.second - std::max(inter.first, last);
      last = inter.second;
    }
  }
  return ans;
}

int main() {
  std::cin >> N >> X >> D;
  std::cout << calc() << std::endl;
  return 0;
}

