#include <bits/stdc++.h>
using namespace std;
char d[1000005];
long long res;
int n, m, i, j, k, a, b, c, e[1000005], f[1000005];
int main() {
  scanf("%d", &k);
  scanf("%s", d + 1);
  n = strlen(d + 1);
  for (i = n; i; i--) {
    if (d[i] == '1') {
      a++;
      f[a] = i;
    }
    e[i] = a;
  }
  f[0] = n + 1;
  for (i = n; i; i--) {
    if (e[i] < k) continue;
    e[i] -= k;
    b = f[e[i]];
    a = f[e[i] + 1];
    if (k == 0) {
      if (d[i] == '0') res += f[e[i]] - i;
      continue;
    }
    res += b - a;
    e[i] += k;
  }
  printf("%lld\n", res);
  return 0;
}
