fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let x: i64 = sc.read();
    let d: i64 = sc.read();

    let ans = solve(n, x, d);
    println!("{}", ans);
}

fn solve(n: usize, x: i64, d: i64) -> usize {
    if x == 0 && d == 0 {
        return 1;
    }
    if d == 0 {
        assert_ne!(x, 0);
        return n + 1;
    }
    assert_ne!(d, 0);

    if x == 0 {
        return n * n - n * (n + 1) / 2 + 1;
    }
    assert!(d != 0 && x != 0);

    let lcm = lcm(x.abs() as usize, d.abs() as usize);
    let a = lcm / (d.abs() as usize);
    let b = lcm / (x.abs() as usize);

    let mut ans = 0;
    for group_id in 0..b {
        let mut set = vec![];
        for i in 0..(n + 1) {
            let i = i * b + group_id;
            if i > n {
                break;
            }
            let (from, to) = if i == 0 {
                (0, 0)
            } else {
                ((i - 1) * i / 2, i * n - (i + 1) * i / 2)
            };
            let add = (i / b * a) as i64;
            let (from, to) = if (x < 0) == (d < 0) {
                (from as i64 + add, to as i64 + add)
            } else {
                (from as i64 - add, to as i64 - add)
            };
            set.push((from, to));
        }
        ans += calc(set);
    }

    ans
}

fn calc(mut set: Vec<(i64, i64)>) -> usize {
    set.sort();

    let mut ans = 0;

    let mut prev: Option<(i64, i64)> = None;

    for (from, to) in set.into_iter() {
        match prev {
            Some((prev_from, prev_to)) => {
                assert!(prev_from <= from);
                if prev_to >= to {
                    prev = Some((prev_from, prev_to));
                } else if prev_to >= from {
                    prev = Some((prev_from, to));
                } else {
                    ans += prev_to - prev_from + 1;
                    prev = Some((from, to));
                }
            }
            None => {
                prev = Some((from, to));
            }
        }
    }

    if let Some((from, to)) = prev {
        ans += to - from + 1;
    }
    assert!(ans >= 0);
    ans as usize
}

fn lcm(a: usize, b: usize) -> usize {
    let g = gcd(a, b);
    a / g * b
}

fn gcd(a: usize, b: usize) -> usize {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 9464