#define STOPIT
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_a_genius = 0; ngtkana_is_a_genius < int(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (lint i = lint(begin); (i) < lint(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

template < template < typename ... > class Tuple,  typename... Args, std::size_t ... Inds, std::size_t = std::tuple_size< Tuple < Args ... > >::value >
std::istream& tuple_input_impl(std::istream& os, Tuple<Args...>& tuple, std::integer_sequence<std::size_t, Inds...>)
  { (void)std::initializer_list<int>{((void)(os >> std::get< Inds >(tuple)), 0)...}; return os; }
template < template < typename ... > class Tuple,  typename... Args, std::size_t = std::tuple_size< Tuple < Args ... > >::value >
std::istream& operator>> (std::istream& os, Tuple<Args...>& tuple)
  { return tuple_input_impl(os, tuple, std::index_sequence_for<Args...>()); }

template < template < typename ... > class Tuple,  typename... Args, std::size_t ... Inds, std::size_t = std::tuple_size< Tuple < Args ... > >::value >
std::ostream& tuple_output_impl(std::ostream& os, const Tuple<Args...>& tuple, std::integer_sequence<std::size_t, Inds...>)
  { os << "("; (void)std::initializer_list<int>{((void)(os << (Inds > 0 ? "," : "") << std::get< Inds >(tuple)), 0)...}; return os << ")"; }
template < template < typename ... > class Tuple,  typename... Args, std::size_t = std::tuple_size< Tuple < Args ... > >::value >
std::ostream& operator<< (std::ostream& os, const Tuple<Args...>& tuple)
 { return tuple_output_impl(os, tuple, std::index_sequence_for<Args...>()); }

auto divmod = [&] (lint a, lint b) {
  assert(b > 0);
  lint q = a / b;
  lint r = a % b;
  if (r < 0) {
    q--;
    r += b;
  }
  assert(0 <= r && r < b && a == b*q+r);
  return std::make_pair(q,r);
};

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  lint n, A, B;
  std::cin >> n >> A >> B;
  if (B == 0) {
    lint ans = A == 0 ? 1 : n+1;
    std::cout << ans << std::endl;
    return 0;
  }
  if (B < 0) {
    B = -B;
    A -= (n-1) * B;
  }
  debug(A,B);

  std::map<lint,std::vector<std::pair<lint,lint>>> map;
  rep(i,0,n+1) {
    lint base = i*A;
    lint min = i*(i-1)/2;
    lint max = i*(2*n-i-1)/2;
    lint q,r; std::tie(q,r) = divmod(base,B);
    map[r];
    // debug(i,q,r,min,max);
    map.at(r).emplace_back(q+min,q+max);
  }
  debug(map);

  lint inf = std::numeric_limits<lint>::max();
  lint ans = 0;
  for (auto&& entry : map) {
    auto & v = entry.second;
    std::sort(all(v));
    lint now = 0;
    lint R = -inf, L = -inf;
    for (auto&& pair : v) {
      lint l,r; std::tie(l,r) = pair;
      if (R < l) {
        if (L != -inf && R != -inf) {
          debug(L,R,R-L+1);
          now += R-L+1;
        }
        L = l;
        R = r;
      } else {
        cmx(R,r);
      }
    }
    debug(L,R,R-L+1);
    assert(R != -inf && L != -inf);
    now += R-L+1;
    debug(now);
    ans += now;
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 22144