#include <bits/stdc++.h>
using namespace std;
char in[1000000 + 5];
int mem[1000000 + 5];
int main() {
  int k, slen;
  scanf("%d", &k);
  scanf("\n%s", in);
  slen = strlen(in);
  int cnt = 0;
  for (int i = 0; i < slen; i++) {
    if (in[i] == '1') cnt++;
    mem[i] = cnt;
  }
  long long ans = 0;
  for (int i = 0; i < slen; i++) {
    if (k == 0 && in[i] == '1') continue;
    int lookfor = mem[i - 1] + k;
    ans += (long long)(upper_bound(mem + i, mem + slen, lookfor) -
                       lower_bound(mem + i, mem + slen, lookfor));
  }
  printf("%I64d\n", ans);
  return 0;
}
