output_description: Print the number of possible values of S - T.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N X D
attempt: N, x, d = map(int, input().split())
  
  ans = 0
  
  
  def sum_difference():
      if d < 0:
          D = -d
          X = -x
      else:
          D = d
          X = x
  
      if D == 0:
          if X == 0:
              return 1
          else:
              return N + 1
  
      S1 = [[]] * D
      S2 = [[]] * D
      for k in range(0, N + 1):  # 条件より、N>=1
          m = k * X % D
          # k個選んだ時の和の最小値、最大値
          Smin = int(k * X + D * (k * (k - 1) / 2))
          Smax = int(k * X + D * (k * (2 * N - k - 1) / 2))
  
          if S1[m] == []:
              S1[m] = [Smin]
              S2[m] = [Smax]
          else:
              if Smax < S1[m][-1]:
                  S1[m].append(Smin)
                  S2[m].append(Smax)
              elif Smin < S1[m][-1] and Smax <= S2[m][-1]:
                  S1[m][-1] = Smin
              elif Smin <= S2[m][-1] and S2[m][-1] < Smax:
                  S2[m][-1] = Smax
              elif S2[m][-1] < Smin:
                  S1[m].append(Smin)
                  S2[m].append(Smax)
  
      cnt = 0
      for mm in range(D):
          for c1, c2 in zip(S1[mm], S2[mm]):
              cnt += (c2 - c1) // D + 1
  
      return int(cnt)
  
  
  ans = sum_difference()
  print(ans)
  
problem_description: Statement
  
  We have an integer sequence A of length N, where A_1 = X, A_{i+1} = A_i + D (1
  \leq i < N ) holds.
  
  Takahashi will take some (possibly all or none) of the elements in this
  sequence, and Aoki will take all of the others.
  
  Let S and T be the sum of the numbers taken by Takahashi and Aoki,
  respectively. How many possible values of S - T are there?
samples: [{"input": "3 4 2", "output": "8\n    \n\nA is (4, 6, 8).\n\nThere are eight ways for (Takahashi, Aoki) to take the elements: ((), (4, 6,\n8)), ((4), (6, 8)), ((6), (4, 8)), ((8), (4, 6))), ((4, 6), (8))), ((4, 8),\n(6))), ((6, 8), (4))), and ((4, 6, 8), ()).\n\nThe values of S - T in these ways are -18, -10, -6, -2, 2, 6, 10, and 18,\nrespectively, so there are eight possible values of S - T.\n\n* * *"}, {"input": "2 3 -3", "output": "2\n    \n\nA is (3, 0). There are two possible values of S - T: -3 and 3.\n\n* * *"}, {"input": "100 14 20", "output": "49805"}]