#include <bits/stdc++.h>
using namespace std;
string s;
long long k, n;
int index_1[(int)(1e6 + 5)], num = 0;
void solve() {
  cin >> k >> s;
  n = s.size();
  if (k == 0) {
    long long last = 0, ans = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] == '0')
        last++;
      else {
        ans += last * (last + 1) / 2;
        last = 0;
      }
    }
    ans += last * (last + 1) / 2;
    cout << ans;
    return;
  }
  for (int i = 0; i < n; i++) {
    if (s[i] == '1') index_1[num++] = i;
  }
  long long ans = 0;
  for (int i = k - 1; i < num; i++) {
    long long t1 = n - 1 - index_1[i] + 1;
    if (i < num - 1) t1 = index_1[i + 1] - index_1[i];
    long long t2 = index_1[i - (k - 1)] - 0 + 1;
    if (i - (k - 1) > 0) t2 = index_1[i - (k - 1)] - index_1[i - (k - 1) - 1];
    ans += t1 * t2;
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
}
