#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

#define BR "\n"
#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a, b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it, cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it, cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define MAX(V, T) V=max(V,T)

#define DumpArray(cont, from, to) for(int __i=from;__i<to;++__i) {cout<<"(" <<__i<<": " << cont[__i]<<")";} cout<<endl;

/*
 * ***_bound(6)
 * 5 6 6 6 6 6 7 7 7
 *   ^lower    ^upper
 * void reverse(c.begin(), c.end())
 *
 * graph
 * seg tree
 * dp
 * brute force
 */
struct Comparator{
    int operator()(int l, int r) const {
        return r<l;
    }
};
//set<int, Comparator> S;

struct Vec{
    double v[2];
    string to_s(){
        return "("+to_string(v[0])+","+to_string(v[1])+")";
    }
    double& operator[](int t){
        return v[t];
    }
    Vec operator+(Vec t) {
        return {v[0]+t[0],v[1]+t[1]};
    }
    Vec& operator+=(Vec t) {
        v[0]+=t[0];v[1]+=t[1];
        return *this;
    }
    Vec operator-(Vec t) {
        return {v[0]-t[0],v[1]-t[1]};
    }
    Vec& operator-=(Vec t) {
        v[0]-=t[0];v[1]-=t[1];
        return *this;
    }
    Vec operator*(double t) {
        return {v[0]*t,v[1]*t};
    }
    Vec& operator*=(double t) {
        v[0]*=t;v[1]*=t;
        return *this;
    }
    double operator*(Vec t) {
        return v[0]*t[0]+v[1]*t[1];
    }
    Vec operator-(){
        return {-v[0],-v[1]};
    }
    static Vec Z;
};
Vec Vec::Z={0,0};

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef vector<P> VP;
typedef pair<ll,ll> RP;
ll N,X,D;
map<ll,vector<RP> > Set;
ll fmin(ll k) {
    return (0+k-1)*k/2;
}
ll fmax(ll k) {
    return (N-k+N-1)*k/2;
}
int main() {
    cin >> N>> X>>D;
    if (D==0) {
        if (X==0)
            cout<<1<<endl;
        else
            cout<<N+1<<endl;
        exit(0);
    }
    ll ans=0;
    for(ll i=0;i<N+1;++i) {
        ll m=min(fmin(i)*D+i*X,fmax(i)*D+i*X),M=max(fmin(i)*D+i*X,fmax(i)*D+i*X);
        Set[AS_MOD((i*X)%D,D)].push_back({m,1});
        Set[AS_MOD((i*X)%D,D)].push_back({M,0});
    }
    for(auto& p:Set) {
        sort(p.se.begin(), p.se.end(), [](RP &l, RP &r) { return l.fi == r.fi ? l.se>r.se : l.fi < r.fi; });
    }
    for(auto& p:Set) {
        ll st=0;
        ll rt=0;
        for(ll i=0;i<p.se.size();++i) {
            RP rp=p.se[i];
            if (rp.se>0) {
                if (rt==0)st=rp.fi;
                rt++;
            } else {
                rt--;
                if (rt==0) {
                    ans+=(rp.fi-st)/abs(D)+1;
                }
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 25216