#include <bits/stdc++.h>
using namespace std;
map<long long, int> cnt;
int main() {
  int k;
  string str;
  long long ans = 0, sum = 0;
  cin >> k >> str;
  cnt[0] = 1;
  int n = str.length();
  for (int i = 0; i < n; i++) {
    if (str[i] == '1') sum++;
    if (sum >= k) ans += cnt[sum - k];
    cnt[sum]++;
  }
  cout << ans << '\n';
}
