#include <bits/stdc++.h>
using namespace std;
long long sum[1000005];
char str[1000005];
int k;
long long find_upper_bound(int l, int r, int now) {
  while (l + 1 < r) {
    int mid = (l + r) / 2;
    if (sum[mid] - now <= k)
      l = mid;
    else
      r = mid;
  }
  return r;
}
long long find_lower_bound(int l, int r, int now) {
  while (l + 1 < r) {
    int mid = (l + r) / 2;
    if (sum[mid] - now < k)
      l = mid;
    else
      r = mid;
  }
  return r;
}
int main() {
  scanf("%d", &k);
  scanf("%s", str);
  int len = strlen(str);
  for (int i = 1; i <= len; i++) {
    if (str[i - 1] == '1')
      sum[i] = sum[i - 1] + 1;
    else
      sum[i] = sum[i - 1];
  }
  long long ans = 0;
  for (int i = 1; i <= len; i++) {
    long long j = find_upper_bound(i - 1, len + 1, sum[i - 1]) -
                  find_lower_bound(i - 1, len + 1, sum[i - 1]);
    ans = ans + j;
  }
  printf("%I64d\n", ans);
  return 0;
}
