import std.stdio;
import std.string;

void main() {
	ulong n, p;
	string s;
	readf(" %s %s\n%s", &n, &p, &s);
	s = s.chomp;

	ulong count = 0;
	while (s.length > 0) {
		ulong x = 0;
		ulong scale = 1;

		foreach (i;0..s.length) {
			x += cast(ulong)(s[$ - i - 1] - '0') * scale;
			if (x % p == 0) ++count;

			scale *= 10;
		}

		s = s[0..$ - 1];
	}

	writeln(count);
}
