from fractions import gcd

from itertools import accumulate



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



if d == 0:

    if x == 0:

        print((1))

    else:

        print((n + 1))

    exit()

elif d < 0:

    x, d = -x, -d



g = gcd(x, d)

back_k = d // g

offset = x // g



lowers = [0] + list(accumulate(list(range(n))))

uppers = [0] + list(accumulate(list(range(n - 1, -1, -1))))

min_memo = [10 ** 18] * min(n + 1, back_k)

max_memo = [-(10 ** 18)] * min(n + 1, back_k)

# print(n, x, d, g, back_k, offset)

# print(lowers)

# print(uppers)



ans = 0

for k in range(n + 1):

    min_acc = lowers[k]

    max_acc = uppers[k]



    if k < back_k:

        min_memo[k] = min_acc - offset

        max_memo[k] = max_acc - offset

        ans += max_acc - min_acc + 1

        # print(k, ans, min_acc, max_acc, max_acc - min_acc + 1)

        continue



    kk = k % back_k

    back_min = min_memo[kk]

    back_max = max_memo[kk]



    if back_max < min_acc or max_acc < back_min:

        min_memo[kk] = min_acc - offset

        max_memo[kk] = max_acc - offset

        ans += max_acc - min_acc + 1

    else:

        current = max_acc - min_acc + 1

        duplicated = min(max_acc, back_max) - max(min_acc, back_min) + 1

        ans += current - duplicated

        min_memo[kk] = min(min_acc, back_min) - offset

        max_memo[kk] = max(max_acc, back_max) - offset



    # print(k, ans, min_acc, max_acc, back_min, back_max)



print(ans)

from fractions import gcd

from itertools import accumulate





def solve(n, x, d):

    if d == 0:

        return 1 if x == 0 else n + 1

    elif d < 0:

        x, d = -x, -d



    g = gcd(x, d)

    x //= g

    d //= g



    lowers = [0] + list(accumulate(list(range(n))))

    uppers = [0] + list(accumulate(list(range(n - 1, -1, -1))))

    ans = 0

    for k_mod in range(min(n + 1, d)):

        k = k_mod

        offset = 0

        endpoints = []

        while k <= n:

            endpoints.append((lowers[k] + offset, 0))

            endpoints.append((uppers[k] + offset, 1))

            k += d

            offset += x

        endpoints.sort()

        opening = 0

        current_left = 0

        for s, t in endpoints:

            if t == 0:

                if opening == 0:

                    current_left = s

                opening += 1

            else:

                opening -= 1

                if opening == 0:

                    ans += s - current_left + 1



    return ans





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

print((solve(n, x, d)))

from fractions import gcd
from itertools import accumulate

n, x, d = list(map(int, input().split()))
if d == 0:
    if x == 0:
        print((1))
    else:
        print((n + 1))
    exit()
elif d < 0:
    x, d = -x, -d
g = gcd(x, d)
back_k = d // g
offset = x // g
lowers = [0] + list(accumulate(list(range(n))))
uppers = [0] + list(accumulate(list(range(n - 1, -1, -1))))
min_memo = [10**18] * min(n + 1, back_k)
max_memo = [-(10**18)] * min(n + 1, back_k)
# print(n, x, d, g, back_k, offset)
# print(lowers)
# print(uppers)
ans = 0
for k in range(n + 1):
    min_acc = lowers[k]
    max_acc = uppers[k]
    if k < back_k:
        min_memo[k] = min_acc - offset
        max_memo[k] = max_acc - offset
        ans += max_acc - min_acc + 1
        # print(k, ans, min_acc, max_acc, max_acc - min_acc + 1)
        continue
    kk = k % back_k
    back_min = min_memo[kk]
    back_max = max_memo[kk]
    if back_max < min_acc or max_acc < back_min:
        min_memo[kk] = min_acc - offset
        max_memo[kk] = max_acc - offset
        ans += max_acc - min_acc + 1
    else:
        current = max_acc - min_acc + 1
        duplicated = min(max_acc, back_max) - max(min_acc, back_min) + 1
        ans += current - duplicated
        min_memo[kk] = min(min_acc, back_min) - offset
        max_memo[kk] = max(max_acc, back_max) - offset
    # print(k, ans, min_acc, max_acc, back_min, back_max)
print(ans)

from fractions import gcd
from itertools import accumulate


def solve(n, x, d):
    if d == 0:
        return 1 if x == 0 else n + 1
    elif d < 0:
        x, d = -x, -d
    g = gcd(x, d)
    x //= g
    d //= g
    lowers = [0] + list(accumulate(list(range(n))))
    uppers = [0] + list(accumulate(list(range(n - 1, -1, -1))))
    ans = 0
    for k_mod in range(min(n + 1, d)):
        k = k_mod
        offset = 0
        endpoints = []
        while k <= n:
            endpoints.append((lowers[k] + offset, 0))
            endpoints.append((uppers[k] + offset, 1))
            k += d
            offset += x
        endpoints.sort()
        opening = 0
        current_left = 0
        for s, t in endpoints:
            if t == 0:
                if opening == 0:
                    current_left = s
                opening += 1
            else:
                opening -= 1
                if opening == 0:
                    ans += s - current_left + 1
    return ans


n, x, d = list(map(int, input().split()))
print((solve(n, x, d)))

+ +def solve(n, x, d): +    if d == 0: +        return 1 if x == 0 else n + 1 +    elif d < 0: +        x, d = -x, -d +    g = gcd(x, d) +    x //= g +    d //= g +    lowers = [0] + list(accumulate(list(range(n)))) +    uppers = [0] + list(accumulate(list(range(n - 1, -1, -1)))) +    ans = 0 +    for k_mod in range(min(n + 1, d)): +        k = k_mod +        offset = 0 +        endpoints = [] +        while k <= n: +            endpoints.append((lowers[k] + offset, 0)) +            endpoints.append((uppers[k] + offset, 1)) +            k += d +            offset += x +        endpoints.sort() +        opening = 0 +        current_left = 0 +        for s, t in endpoints: +            if t == 0: +                if opening == 0: +                    current_left = s +                opening += 1 +            else: +                opening -= 1 +                if opening == 0: +                    ans += s - current_left + 1 +    return ans + + -if d == 0: -    if x == 0: -        print((1)) -    else: -        print((n + 1)) -    exit() -elif d < 0: -    x, d = -x, -d -g = gcd(x, d) -back_k = d // g -offset = x // g -lowers = [0] + list(accumulate(list(range(n)))) -uppers = [0] + list(accumulate(list(range(n - 1, -1, -1)))) -min_memo = [10**18] * min(n + 1, back_k) -max_memo = [-(10**18)] * min(n + 1, back_k) -# print(n, x, d, g, back_k, offset) -# print(lowers) -# print(uppers) -ans = 0 -for k in range(n + 1): -    min_acc = lowers[k] -    max_acc = uppers[k] -    if k < back_k: -        min_memo[k] = min_acc - offset -        max_memo[k] = max_acc - offset -        ans += max_acc - min_acc + 1 -        # print(k, ans, min_acc, max_acc, max_acc - min_acc + 1) -        continue -    kk = k % back_k -    back_min = min_memo[kk] -    back_max = max_memo[kk] -    if back_max < min_acc or max_acc < back_min: -        min_memo[kk] = min_acc - offset -        max_memo[kk] = max_acc - offset -        ans += max_acc - min_acc + 1 -    else: -        current = max_acc - min_acc + 1 -        duplicated = min(max_acc, back_max) - max(min_acc, back_min) + 1 -        ans += current - duplicated -        min_memo[kk] = min(min_acc, back_min) - offset -        max_memo[kk] = max(max_acc, back_max) - offset -    # print(k, ans, min_acc, max_acc, back_min, back_max) -print(ans) +print((solve(n, x, d)))