#include <bits/stdc++.h>
using namespace std;
int main(int argc, char **argv) {
  int n;
  unsigned long long ans;
  string str;
  cin >> n >> str;
  map<int, vector<int> > myMap;
  myMap[0].push_back(0);
  int cur = 0;
  ans = 0;
  for (int i = 0; i < str.size(); i++) {
    if (str[i] == '0') {
    } else {
      cur++;
    }
    if (cur >= n && myMap.count(cur - n) != 0) {
      ans += myMap[cur - n].size();
    }
    myMap[cur].push_back(i);
  }
  cout << ans << endl;
  return 0;
}
