#include <bits/stdc++.h>
using namespace std;
int k, n, dp[1000005], H[1000005];
char s[1000005];
int main() {
  long long cnt = 0, a = 0;
  cin >> k >> s + 1;
  n = strlen(s + 1);
  for (int i = 1; i <= n; i++) {
    dp[i] = dp[i - 1] + (s[i] == '1');
  }
  H[0] = 1;
  for (int i = 1; i <= n; i++) {
    a = dp[i] - k;
    if (a >= 0) cnt += H[a];
    H[dp[i]]++;
  }
  cout << cnt << endl;
  return 0;
}
