#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1000 * 1000 + 10;
int dp[MAX_N];
string s;
int main() {
  int k, sum = 0;
  cin >> k >> s;
  dp[0] = 1;
  long long ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '1') sum++;
    if (sum >= k) ans += dp[sum - k];
    dp[sum]++;
  }
  cout << ans << endl;
  return 0;
}
