#include <bits/stdc++.h>
using namespace std;
static const int MAX_N = 1e6 + 5;
static const int N = 305;
static const long long Mod = 2009;
static const int inf = (1 << 30) - 1;
char str[MAX_N];
int ans[MAX_N], f[MAX_N];
void solve() {
  int k;
  scanf("%d%s", &k, str);
  int le = strlen(str);
  for (int i = 0; i < le; ++i) f[i + 1] = f[i] + (str[i] == '1');
  ans[0] = 1;
  long long res = 0;
  for (int i = 1; i <= le; ++i) {
    int d = f[i] - k;
    if (d >= 0) res += ans[d];
    ++ans[f[i]];
  }
  printf("%I64d\n", res);
}
int main() {
  solve();
  return 0;
}
