#include<bits/stdc++.h>
using namespace std;

using Lint=long long;
using P=pair<Lint,Lint>;

Lint mydiv(Lint a,Lint b)
{
   if(a>=0 or a%b==0) return a/b;
   return a/b-1;
}
Lint mymod(Lint a,Lint b)
{
   if(a>=0 or a%b==0) return a%b;
   return a%b+b;
}
Lint sum(Lint a,Lint b)
{
   return (a+b)*(b-a+1)/2;
}

int main()
{
   int N,X,D; cin>>N>>X>>D;
   if(D==0){
      if(X==0) cout<<1<<endl;
      else cout<<N+1<<endl;
      return 0;
   }
   if(D<0) X=-X,D=-D;

   map<int,vector<P>> mp;
   mp[0].push_back({0,0});
   for(int k=1;k<=N;k++){
      Lint l=mydiv((Lint)k*X,D)+sum(0,k-1);
      Lint r=mydiv((Lint)k*X,D)+sum(N-k,N-1);
      mp[mymod((Lint)k*X,D)].push_back({l,r});
   }

   Lint ans=0;
   for(auto p:mp){
      auto events=p.second;
      /*
      printf("%d: ",p.first);
      for(auto q:events) printf("(%lld,%lld) ",q.first,q.second); puts("");
      */
      sort(events.begin(),events.end());
      Lint s,t; tie(s,t)=events[0];
      for(auto q:events){
         if(q.first<=t) t=max(t,q.second);
         else ans+=t-s+1,tie(s,t)=q;
      }
      ans+=t-s+1;
   }
   cout<<ans<<endl;
   return 0;
}