use std::io::BufReader;
use std::io::BufRead;
use std::io;

fn main() {
    let reader = io::stdin();
    let mut stdin = BufReader::new(reader.lock());
    let mut buf = String::new();
    let mut ans = String::new();

    let _ = stdin.read_line(&mut buf);
    let vec: Vec<u64> = buf.split_whitespace().map(|x| x.parse().unwrap()).collect();
    let n = vec[0];
    let m = vec[1];
    let mut ans = 0u64;

    buf.clear();

    let ai: Vec<u64> = buf.split_whitespace().map(|x| x.parse().unwrap()).collect();

    for i in 0..n + 1 {
        for j in i..n + 1 {
            let mut sum = 0;

            for k in i..j + 1 {
                sum += k;
            }
            if sum % m == 0 {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}

