object Main {
    def main(args: Array[String]) {
        val factors    = scala.io.StdIn.readLine().split(" ").map(_.toInt)
        val candy_nums = scala.io.StdIn.readLine().split(" ").map{_.toInt()}
        println(countNum(calcNum(candy_nums, factors(1))))
    }

    def countNum(candy_nums: Array[Int], children_nums: Int)
    {
        var count = 0
        for(i <- 1 to Math.pow(2, candy_nums.length) - 1) {
            var sum = 0
            var check = i
            var chandy_count = 0
            while(check < 1) {
                if(check%2 == 1) {
                    sum += chandy_nums[chandy_count]
                    sum =  sum%children_nums
                }
                check = check/2
                chandy_count += 1
            }
            if(sum%children_nums == 0) {count += 1}
        }
    }
}