#include <bits/stdc++.h>
using namespace std;
const int MAX = 1000005, oo = 1 << 30;
char s[MAX];
int sum[MAX];
int main() {
  int k, next, back = 0;
  long long ret = 0;
  scanf("%d%s", &k, s + 1);
  sum[0] = 1;
  for (int i = 1; s[i]; ++i) {
    next = back + (s[i] == '1');
    if (next - k >= 0) ret += sum[next - k];
    sum[next]++;
    back = next;
  }
  printf("%I64d\n", ret);
  return 0;
}
