#include <bits/stdc++.h>
using namespace std;
map<int, int> m;
long long k;
char s[1000005];
long long l[1000005], r[1000005], vt[1000005];
void solve() {
  long long i, ln, dau, tm, pt, tong;
  tong = 0;
  pt = 0;
  m.clear();
  gets(s), gets(s);
  ln = strlen(s);
  for (i = 0; i < ln; i++) {
    if (s[i] == '0') l[i + 1]++;
    if (i > 0 && s[i - 1] == '0' && s[i] == '0') l[i + 1] += l[i];
    m[s[i] - 48]++;
  }
  if (k == 0) {
    for (i = 1; i <= ln + 1; i++) tong += l[i] + r[i + 1];
    printf("%I64d\n", tong);
    return;
  }
  if (k > m[1]) {
    printf("0\n");
    return;
  }
  for (i = ln - 1; i >= 0; i--) {
    if (s[i] == '0') r[i + 1]++;
    if (i + 1 < ln && s[i + 1] == '0' && s[i] == '0') r[i + 1] += r[i + 2];
  }
  tm = 0;
  dau = 1;
  for (i = 0; i < ln; i++) {
    if (s[i] == '1') tm++, vt[++pt] = i;
    if (tm == k) {
      tong += l[vt[dau] - 1 + 1] * (r[i + 1 + 1] + 1) + 1 + (r[i + 1 + 1]);
      dau++;
      tm--;
    }
  }
  printf("%I64d\n", tong);
}
int main() {
  while (scanf("%I64d", &k) > 0) solve();
  return 0;
}
