#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int k;
  cin >> k;
  string s;
  cin >> s;
  long long int n = s.length();
  map<long long int, long long int> m;
  long long int a[n];
  long long int c = 0;
  for (long long int i = 0; i < n; i++) {
    if (s[i] == '1') {
      c++;
    }
    a[i] = c;
    m[a[i]]++;
  }
  long long int ans = 0;
  c = 0;
  if (k == 0) {
    for (long long int i = 0; i < n; i++) {
      if (s[i] == '0') {
        c++;
      } else {
        ans += (c * (c + 1)) / 2;
        c = 0;
      }
    }
    if (c != 0) {
      ans += (c * (c + 1)) / 2;
    }
    cout << ans << endl;
  } else {
    ans = m[k];
    for (long long int i = 0; i < n; i++) {
      ans += (m[k + a[i]]);
    }
    cout << ans << endl;
  }
  return 0;
}
