program sum_difference
  implicit none
  integer(8) :: n, x, d, t, k
  read(*,*) n, x, d
  if (d == 0) then
    if (x == 0) then
      write(*,'(i0)') 1
    else
      write(*,'(i0)') n+1
    end if
    stop
  else if (x == 0) then
    write(*,'(i0)') n*(n-1)/2+1
    stop
  else if (x < 0) then
    x = -x
    d = -d
  end if
  t = gcd(x,d)
  x = x/t
  d = d/t
  t = (n+1)*(n**2-n+6)/6
  do k = 0, n
    t = t-f(k)
  end do
  write(*,'(i0)') t
contains
  integer(8) function gcd(a,b)
    integer(8), intent(in) :: a, b
    integer(8) :: x, y
    x = max(abs(a),abs(b))
    y = min(abs(a),abs(b))
    do while (y > 0)
      gcd = y
      y = mod(x,y)
      x = gcd
    end do
  end
  integer(8) function f(k)
    integer(8), intent(in) :: k
    integer(8) :: l1, l2, r1, r2
    l1 = k*(n*2-k-1)/2
    l2 = k*(k-1)/2
    r1 = (k+d)*(n*2-k-d-1)/2+x
    r2 = (k+d)*(k+d-1)/2+x
    f = max(min(l1,r1)-max(l2,r2)+1,0)
  end
end program sum_difference