#include <bits/stdc++.h>
using namespace std;
int a[1000005];
char s[1000005];
int main() {
  int K;
  scanf("%d%s", &K, s);
  int n = strlen(s), N = 0;
  for (int i = 0; i < n; i++)
    if (s[i] == '1') a[N++] = i;
  long long ret = 0;
  if (K == 0) {
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] == '1') {
        ret += (long long)cnt * (cnt + 1) / 2;
        cnt = 0;
      } else
        cnt++;
    }
    ret += (long long)cnt * (cnt + 1) / 2;
    printf("%I64d\n", ret);
    return 0;
  }
  a[N] = n;
  for (int i = 0; i < N; i++) {
    if (i == 0) {
      if (i + K - 1 < N)
        ret += (long long)(a[i + K] - a[i + K - 1]) * (a[0] + 1);
    } else {
      if (i + K - 1 < N)
        ret += (long long)(a[i + K] - a[i + K - 1]) * (a[i] - a[i - 1]);
    }
  }
  printf("%I64d\n", ret);
  return 0;
}
