#include <bits/stdc++.h>
using namespace std;
int main() {
  int k;
  scanf("%d", &k);
  string s;
  cin >> s;
  int i;
  long long ans = 0;
  if (k == 0) {
    long long w = 0;
    for (i = 0; i < s.size(); i++) {
      if (s[i] == '0')
        w++;
      else {
        ans += ((w * (w + 1)) / 2);
        w = 0;
      }
    }
    printf("%I64d", ans + ((w * (w + 1)) / 2));
    return 0;
  }
  vector<int> a;
  int stIndex = 0, ndIndex = 0, j;
  long long d = 0, q = 0;
  for (i = 0; i < s.size(); i++)
    if (s[i] == '1') a.push_back(i);
  for (i = 0; i < a.size(); i++)
    if (i + k - 1 < a.size()) {
      d = 0, q = 0;
      if (i == 0) {
        if (a[i] != 0) d = a[i];
      } else
        d = a[i] - 1 - a[i - 1];
      if (i + k < a.size())
        q = a[i + k] - a[i + k - 1] - 1;
      else
        q = s.size() - a[i + k - 1] - 1;
      ans += ((q + 1) * (d + 1));
    }
  printf("%I64d", ans);
  return 0;
}
