#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

#define _USE_MATH_DEFINES

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <stack>
#include <list>
#include <math.h>
#include <bitset>
#include <iterator>
#include <map>
#include <iomanip>
#include <functional>
#include <string>
#include <algorithm>
#include <queue>
#include <random>
#include <numeric>
#include <set>
#include <cassert>
#include <cmath>
#include <cinttypes>

using namespace std;

template<class T> ostream& operator<<(ostream& os, const vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) os << *i << (i == end(v) - 1 ? "" : " "); return os;
}
template<class T> istream& operator>>(istream& is, vector<T>& v) {
	for (auto i = begin(v); i != end(v); i++) is >> *i; return is;
}
template<class T> T read_val() { throw 1; }
template<> int read_val() { int tmp; scanf("%" PRId32, &tmp); return tmp; }
template<> long long read_val() { long long tmp; scanf("%" PRId64, &tmp); return tmp; }
auto read_int = read_val<int>; auto read_long = read_val<long long>;
template<class T> void scanf_vec(vector<T>& vec) { for (int i = 0; i < vec.size(); i++) vec[i] = read_val<T>(); }

#define MOD 1000000007
#define inf 2000000000
#define FWT_SIZE 2000000
#define pii pair<int,int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define sort_all(x) sort(all(x))
#define make_unique(x) (x).erase(unique(all(x)), (x).end())

template<typename T>
inline T fast_gcd(T a, T b)
{
	T c;
	while (b)
	{
		c = b;
		b = a % b;
		a = c;
	}
	return a;
}


long long ternary(int left, int right, const std::function<long long(int)> &func)
{
	if (right - left < 10)
	{
		long long mv = 0;
		for (int i = left; i <= right; i++)
		{
			mv = max(mv, func(i));
		}

		return mv;
	}

	int step = (right - left) / 3;
	if (func(left + step) < func(left + step * 2))
		return ternary(left + step, right, func);
	else
		return ternary(left, right - step, func);
}

int main() {

#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n;
	long long x, d;
	cin >> n >> x >> d;

	if (d == 0)
	{
		if (x == 0)
			cout << 1;
		else
			cout << n+1;
		return 0;
	}

	long long alpha = d, beta = x;
	alpha /= fast_gcd(d, x);
	beta /= fast_gcd(d, x);

	if (alpha < 0)
	{
		alpha *= -1LL;
		beta *= -1LL;
	}

	vector<pair<long long, long long>> ranges;
	ranges.push_back({ 0,0 });
	long long left = 0, right = 0;
	long long left_p = 0, right_p = n-1;
	for (int i =1; i <= n;i++)
	{
		left += left_p;
		right += right_p;
		left_p++; right_p--;
		ranges.push_back({ left,right });
	}

	long long ans = 0;
	for (int i = 0; i <= n; i++)
	{
		long long range = ranges[i].second - ranges[i].first + 1LL;
		if (i >= alpha)
		{
			long long left_r = ranges[i-alpha].first - beta;
			long long right_r = ternary(1, i / alpha, [&](int idx) {
				return ranges[i - idx * alpha].second - beta * idx;
				});
			right_r = ranges[i - alpha].second - beta;
			if (left_r <= right_r)
			{
				long long cand = min(ranges[i].second, right_r) - max(ranges[i].first, left_r) + 1LL;;
				range -= max(cand, 0LL);
			}

		}

		ans += range;
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 6512