#include <bits/stdc++.h>
using namespace std;
long long int mul(long long int a, long long int b) {
  return ((a % int(1e9 + 7)) * (b % int(1e9 + 7))) % int(1e9 + 7);
}
long long int add(long long int a, long long int b) {
  return ((a % int(1e9 + 7)) + (b % int(1e9 + 7))) % int(1e9 + 7);
}
long long int sub(long long int a, long long int b) {
  long long int ans = ((a % int(1e9 + 7)) - (b % int(1e9 + 7))) % int(1e9 + 7);
  ans %= int(1e9 + 7);
  ans = (ans + int(1e9 + 7)) % int(1e9 + 7);
  return ans;
}
long long int mpow(long long int a, long long int b) {
  long long int ans = 1;
  long long int po = a;
  while (b != 0) {
    if (b % 2) {
      ans = ((ans % int(1e9 + 7)) * (po % int(1e9 + 7))) % int(1e9 + 7);
    }
    po = ((po % int(1e9 + 7)) * (po % int(1e9 + 7))) % int(1e9 + 7);
    b /= 2;
  }
  return ans;
}
void solve() {
  long long int k, n;
  cin >> k;
  string s;
  cin >> s;
  n = s.length();
  long long int lo = 0, hi = -1, cnt = 0, ans = 0;
  while (lo < n) {
    while (hi + 1 < n and (s[hi + 1] == '0' or cnt + 1 <= k)) {
      hi++;
      if (s[hi] == '1') cnt++;
    }
    ans += (hi - lo + 1);
    if (hi < lo) {
      lo++;
      hi = lo - 1;
      cnt = 0;
    } else {
      if (s[lo] == '1') cnt--;
      lo++;
    }
  }
  if (k == 0) {
    cout << ans << '\n';
    return;
  }
  k--;
  lo = 0, hi = -1, cnt = 0;
  while (lo < n) {
    while (hi + 1 < n and (s[hi + 1] == '0' or cnt + 1 <= k)) {
      hi++;
      if (s[hi] == '1') cnt++;
    }
    ans -= (hi - lo + 1);
    if (hi < lo) {
      lo++;
      hi = lo - 1;
    } else {
      if (s[lo] == '1') cnt--;
      lo++;
    }
  }
  cout << ans << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  solve();
}
