#include <bits/stdc++.h>
using namespace std;
long long int a[1000007], d[1000007];
char c[1000007];
void solve(int k) {
  long long int i, j, r, l, s, n, kol = 0, l1, rot = 0;
  gets(c);
  gets(c);
  n = strlen(c);
  a[0] = c[0] - '0';
  for (i = 1; i < n; i++) {
    a[i] = c[i] - '0';
  }
  d[n - 1] = 0;
  for (i = n - 2; i >= 0; i--) {
    if (a[i] == 1) {
      rot = 0;
    } else {
      rot++;
    }
    d[i] = rot;
  }
  if (k == 0) {
    l = 0;
    s = 0;
    for (r = 0; r < n; r++) {
      s += a[r];
      l1 = l;
      if (s == 0) {
        kol = (r - l1 + 1) + kol;
      }
      while (s > 0) {
        s -= a[l];
        l++;
      }
    }
    printf("%I64d\n", kol);
  } else {
    l = 0;
    s = 0;
    for (r = 0; r < n; r++) {
      s += a[r];
      if (s == k) {
        kol++;
      }
      while (s > k) {
        s -= a[l];
        l++;
        if (s == k) {
          kol++;
        }
      }
      l1 = l;
      if (s == k) {
        kol += d[l];
      }
    }
    printf("%I64d\n", kol);
  }
  return;
}
int main() {
#pragma comment(linker, "/STACK:67108864")
  long long int n;
  while (scanf("%I64d", &n) != EOF) {
    solve(n);
  }
  return 0;
}
