#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int n, k, i, j;
  long long ans = 0;
  cin >> k;
  cin >> s;
  n = s.size();
  int prev = -1;
  int cnt = 0;
  vector<int> v;
  v.push_back(-1);
  for (i = 0; i < n; i++) {
    if (s[i] == '1') {
      v.push_back(i);
    }
  }
  v.push_back(n);
  int m = v.size();
  long long x, y;
  if (m - 2 < k) {
    cout << "0\n";
    return 0;
  }
  if (k == 0) {
    for (i = 1; i < m; i++) {
      x = ((v[i]) - (v[i - 1] + 1));
      ans += (x * (x + 1) / 2);
    }
    cout << ans << "\n";
    return 0;
  }
  for (i = k; i < m - 1; i++) {
    x = ((long long)(v[i - k + 1]) - (v[i - k]));
    y = 0;
    if (v[i] != n - 1) {
      y = ((long long)(v[i + 1] - v[i] - 1) * (v[i - k + 1] - v[i - k]));
    }
    ans += (x + y);
  }
  cout << ans << "\n";
  return 0;
}
