#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
string s = "";
int main() {
  ios ::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long k;
  cin >> k;
  cin >> s;
  long long sz = s.size();
  vector<long long> sum(sz);
  sum[0] = int(s[0] == '1');
  for (int i = 1; i < sz; i++) {
    sum[i] = sum[i - 1] + int(s[i] == '1');
  }
  pair<vector<long long>::iterator, vector<long long>::iterator> bound = {
      sum.begin(), sum.end()};
  if (sum[sz - 1] < k) {
    cout << 0 << endl;
    return 0;
  }
  long long ans = 0;
  long long x;
  for (int i = 0; i < sz; i++) {
    if (sum[i] < k) continue;
    x = sum[i] - k;
    bound = equal_range(sum.begin(), sum.begin() + i, x);
    ans += bound.second - bound.first + int(x == 0);
  }
  cout << ans << endl;
  return 0;
}
