import math
import sys
import functools

mem = []

def comb(n, k):
	if n <= 1 and k <= 1:
		return 1
	return myf(n) / (myf(k) * myf(n - k))


def myf(n):
	if n <= 1:
		return 1
	return myf(n - 1) * n;

n, k = list(map(int, sys.stdin.readline().split(" ")))
num = input()

if k == 0:
	if int(num, 2) == 0:
		print(1)
	else:
		 print(0)
	exit(0)

pos = 0
count = 0
res = 0
onec = 0

for c in num:
	if c == '1':
		onec += 1

def fn(st, k):
	for i in range(len(st)):
		if st[i] == '1':
			k -= 1
			if k == 0:
				return st[:i+1] + ''.join(['0' for x in range(i + 1, len(st))])

nummax = int(num, 2) + pow(2, len(num)) - 1
nummax = fn(bin(nummax)[2:], k) 

#print(nummax)

res2 = 1
for c in reversed(nummax):
	if c == '1':
		count += 1
		if count <= pos:
			res2 += comb(pos, count)
	pos += 1

count = k - onec
pos = 0
#print(count)
for c in reversed(num):
	if c == '1':
		count += 1
		if count <= pos:
			#print(comb(pos, count))
			res += comb(pos, count)
	pos += 1

print(int(res2 - res))
exit(0)
