#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn bs(mut l: usize, mut r: usize, f: &Fn(usize) -> bool) -> usize {
    while r - l > 1 {
        let m = l + (r - l) / 2;
        if f(m) {
            r = m;
        } else {
            l = m;
        }
    }
    r
}

fn main() {
    input!{
      n: usize,
      m: usize,
      aa: [usize; n],
    }
    //  1<=l<=r<=N
    // SUM(A[l]..A[r]) = aM

    let mut s = vec![0; n+1];
    for i in 1..n+1 {
        s[i] = s[i-1] + aa[i-1];
    }
    let mut ans = 0;
    for l in 1..n+1 {
        let max_s = s[n] - s[l-1];
        let mut k = m;
        let mut left = l-1;
        loop {
            if k > max_s { break; }
            let res = bs(left, n, &|m| {
                s[m] - s[l-1] >= k
            });
            if (s[res] - s[l-1]) == k {
                ans += 1;
            }
            left = res-1;
            k += m;
        }
    }
    println!("{}", ans);
}
