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