#include <bits/stdc++.h>
int c[1000001];
char str[1000001];
int len;
int ct;
long long ans;
int main() {
  int k;
  int i;
  scanf("%d", &k);
  scanf("%s", str);
  len = strlen(str);
  if (k == 0) {
    for (i = 0; i < len; i++) {
      if (str[i] == '0')
        ct++;
      else {
        ans += (long long)ct * (long long)(ct + 1) / 2;
        ct = 0;
      }
    }
    ans += (long long)ct * (long long)(ct + 1) / 2;
  } else if (k > 0) {
    for (i = 0; i < len; i++) {
      if (str[i] == '1') ct++;
      c[ct]++;
    }
    ans = c[k];
    for (i = k; i <= len; i++) ans += (long long)c[i] * (long long)c[i - k];
  }
  printf("%I64d\n", ans);
  scanf(" ");
}
