#include <bits/stdc++.h>
using namespace std;
char s[1000005];
int dp[1000005];
int n, k, i, l, r, d;
long long ans, bal;
int main() {
  cin >> k;
  scanf("%s", s + 1);
  for (i = 1; s[i] != '\0'; i++) {
    dp[i] = dp[i - 1] + (s[i] == '1');
  }
  n = i - 1;
  for (l = 1; l <= n; l++) {
    d = k + dp[l - 1];
    bal = (long long)(upper_bound(dp + l, dp + n + 1, d) -
                      lower_bound(dp + l, dp + n + 1, d));
    ans += bal;
  }
  cout << ans << endl;
}
