#include <bits/stdc++.h>
using namespace std;
long long int me(long long int x, long long int n) {
  if (n == 0)
    return 1;
  else if (n % 2 == 0)
    return me((x * x) % 1000000007, n / 2);
  else
    return (x * me((x * x) % 1000000007, (n - 1) / 2)) % 1000000007;
}
void solve() {
  long long int k;
  cin >> k;
  long long int ans = 0;
  string s;
  cin >> s;
  long long int n = s.length();
  vector<long long int> pre(n + 1);
  pre[0] = 0;
  for (long long int i = 0; i < n; i++) {
    if (s[i] == '1')
      pre[i + 1] = pre[i] + 1;
    else
      pre[i + 1] = pre[i];
  }
  for (long long int i = 1; i <= n; i++) {
    if (pre[i] - k < 0)
      continue;
    else {
      long long int p = pre[i] - k;
      long long int in1 =
          lower_bound((pre).begin(), (pre).end(), p) - pre.begin();
      long long int in2 =
          upper_bound((pre).begin(), (pre).end(), p) - pre.begin();
      in2 = min(in2, i);
      ans += in2 - in1;
    }
  }
  cout << ans;
}
signed main() {
  ios_base::sync_with_stdio(false);
  long long int t = 1;
  while (t--) solve();
  return 0;
}
