#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  int k;
  cin >> k;
  string s;
  cin >> s;
  map<int, unsigned long long> m;
  unsigned long long sum = 0;
  unsigned long long ans = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == '1') {
      sum++;
    }
    if (sum == k) {
      ans++;
      ans += m[0];
    } else if (sum > k) {
      ans += m[sum - k];
    }
    m[sum]++;
  }
  cout << ans << endl;
  return 0;
}
