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