#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, l = 0, r = 0, sm = 0, k, i;
  long long ans = 0;
  string s;
  cin >> k >> s;
  n = s.size();
  vector<long long> ll(n, 0), rr(n, 0);
  for (i = 1; i < n; i++)
    if (s[i - 1] == '1')
      ll[i] = 0;
    else
      ll[i] = ll[i - 1] + 1;
  for (i = n - 2; i >= 0; i--)
    if (s[i + 1] == '1')
      rr[i] = 0;
    else
      rr[i] = rr[i + 1] + 1;
  if (k == 0) {
    for (i = 0; i < n; i++)
      if (s[i] == '1') ans += (ll[i] + 1) * ll[i] / 2;
    bool f = true;
    for (i = n - 1; i >= 0; i--)
      if (s[i] == '1') {
        ans += (rr[i] + 1) * rr[i] / 2;
        f = false;
        break;
      }
    if (f)
      cout << (n + 1) * n / 2;
    else
      cout << ans;
    return 0;
  }
  while (l < n && s[l] != '1') l++;
  r = l;
  sm = 1;
  while (r < n && sm < k) {
    r++;
    if (s[r] == '1') sm++;
  }
  while (r < n && l < n) {
    while (r < n && s[r] == '0') r++;
    while (l < n && s[l] == '0') l++;
    if (l == n || r == n) break;
    ans += (ll[l] + 1) * (rr[r] + 1);
    l++;
    r++;
  }
  cout << ans << endl;
  return 0;
}
