#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+100;
ll x,d,ans; int n;
struct Node{
    ll p,l,r;
}a[N];
bool cmp(Node &a,Node &b){
    if(a.p!=b.p) return a.p<b.p;
    else return a.l<b.l;
}
int main(){
    scanf("%d %lld %lld",&n,&x,&d);
    if(d==0){
        printf("%d\n",x==0?1:n+1);
        return 0;
    }
    if(d<0) x=-x,d=-d;
    for(int i=0;i<=n;++i){
        a[i].p=i*x%d;
        a[i].l=1LL*i*(i-1)/2+i*x/d;
        a[i].r=1LL*(n*2-1-i)*i/2+i*x/d;
    }
    sort(a,a+n+1,cmp);
    for(int i=0,j=0;i<=n;i=j){
        ll l=a[i].l,r=a[i].r;
        while(j<=n&&a[j].p==a[i].p&&a[j].l<=r){
            r=max(r,a[j].r); j++;
        }
        ans+=r-l+1;
    }
    printf("%lld\n",ans);
}