import sys

sys.setrecursionlimit(2147483647)

INF=float("inf")

MOD=10**9+7

input=lambda:sys.stdin.readline().rstrip()

from itertools import groupby

def resolve():

    n,a,d=list(map(int,input().split()))

    if(d==0):

        if(a==0): print((1))

        else: print((n+1))

        return

    if(d<0): a,d=-a,-d



    A=[None]*(2*n+2)

    for k in range(n+1):

        L=k*a+k*(k-1)*d//2

        R=k*a+k*(2*n-k-1)*d//2

        r=L%d

        A[2*k]=(r,L//d,0)

        A[2*k+1]=(r,R//d,1)

    A.sort()

    

    ans=0

    for key,iter in groupby(A,lambda x:x[0]):

        now=0

        over=0

        for r,v,q in iter:

            if(q==0):

                if(not over): now=v

                over+=1

            else:

                over-=1

                if(not over): ans+=v-now+1



    print(ans)

resolve()
import sys

sys.setrecursionlimit(2147483647)

INF=float("inf")

MOD=10**9+7

input=lambda:sys.stdin.readline().rstrip()

from collections import defaultdict

def resolve():

    n,a,d=list(map(int,input().split()))

    if(d==0):

        if(a!=0):

            print((n+1))

        else:

            print((1))

        return



    if(d<0): a,d=-a,-d # d>0

    D=defaultdict(list)

    for k in range(n+1):

        q,r=divmod(k*a,d)

        L=q+k*(k-1)//2

        R=q+k*(2*n-k-1)//2

        D[r].append((L,1)) # 1 -> add

        D[r].append((R,2)) # 2 -> remove



    ans=0

    for arr in list(D.values()):

        arr.sort()

        # print(arr)

        over=0

        for v,q in arr:

            if(q==1 and over==0):

                left=v

            over+=1 if(q==1) else -1

            if(over==0):

                ans+=v-left+1

    print(ans)

resolve()
import sys

sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 10**9 + 7
input = lambda: sys.stdin.readline().rstrip()
from itertools import groupby


def resolve():
    n, a, d = list(map(int, input().split()))
    if d == 0:
        if a == 0:
            print((1))
        else:
            print((n + 1))
        return
    if d < 0:
        a, d = -a, -d
    A = [None] * (2 * n + 2)
    for k in range(n + 1):
        L = k * a + k * (k - 1) * d // 2
        R = k * a + k * (2 * n - k - 1) * d // 2
        r = L % d
        A[2 * k] = (r, L // d, 0)
        A[2 * k + 1] = (r, R // d, 1)
    A.sort()
    ans = 0
    for key, iter in groupby(A, lambda x: x[0]):
        now = 0
        over = 0
        for r, v, q in iter:
            if q == 0:
                if not over:
                    now = v
                over += 1
            else:
                over -= 1
                if not over:
                    ans += v - now + 1
    print(ans)


resolve()

import sys

sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 10**9 + 7
input = lambda: sys.stdin.readline().rstrip()
from collections import defaultdict


def resolve():
    n, a, d = list(map(int, input().split()))
    if d == 0:
        if a != 0:
            print((n + 1))
        else:
            print((1))
        return
    if d < 0:
        a, d = -a, -d  # d>0
    D = defaultdict(list)
    for k in range(n + 1):
        q, r = divmod(k * a, d)
        L = q + k * (k - 1) // 2
        R = q + k * (2 * n - k - 1) // 2
        D[r].append((L, 1))  # 1 -> add
        D[r].append((R, 2))  # 2 -> remove
    ans = 0
    for arr in list(D.values()):
        arr.sort()
        # print(arr)
        over = 0
        for v, q in arr:
            if q == 1 and over == 0:
                left = v
            over += 1 if (q == 1) else -1
            if over == 0:
                ans += v - left + 1
    print(ans)


resolve()

-from itertools import groupby +from collections import defaultdict -        if a == 0: +        if a != 0: +            print((n + 1)) +        else: -        else: -            print((n + 1)) -        a, d = -a, -d -    A = [None] * (2 * n + 2) +        a, d = -a, -d  # d>0 +    D = defaultdict(list) -        L = k * a + k * (k - 1) * d // 2 -        R = k * a + k * (2 * n - k - 1) * d // 2 -        r = L % d -        A[2 * k] = (r, L // d, 0) -        A[2 * k + 1] = (r, R // d, 1) -    A.sort() +        q, r = divmod(k * a, d) +        L = q + k * (k - 1) // 2 +        R = q + k * (2 * n - k - 1) // 2 +        D[r].append((L, 1))  # 1 -> add +        D[r].append((R, 2))  # 2 -> remove -    for key, iter in groupby(A, lambda x: x[0]): -        now = 0 +    for arr in list(D.values()): +        arr.sort() +        # print(arr) -        for r, v, q in iter: -            if q == 0: -                if not over: -                    now = v -                over += 1 -            else: -                over -= 1 -                if not over: -                    ans += v - now + 1 +        for v, q in arr: +            if q == 1 and over == 0: +                left = v +            over += 1 if (q == 1) else -1 +            if over == 0: +                ans += v - left + 1