#include <bits/stdc++.h>
enum { MAXN = 1001000 };
int sum[MAXN];
int main() {
  int k, cursum = 0;
  char c;
  long long ans = 0;
  scanf("%d ", &k);
  sum[0] = 1;
  while ((c = getchar()) != '\n') {
    cursum += c - '0';
    if (cursum - k >= 0) ans += sum[cursum - k];
    sum[cursum]++;
  }
  printf("%I64d\n", ans);
  return 0;
}
