#include <bits/stdc++.h>
using namespace std;
int ocu[2000000];
string s;
int main() {
  int k;
  cin >> k;
  cin >> s;
  int i, cur = 0, req;
  long long int ans = 0;
  for (i = 0; i < s.size(); i++) {
    if (s[i] == '1') ocu[++cur] = i + 1;
    if (cur < k) continue;
    req = ocu[cur - k] + 1;
    ans += (ocu[cur - k + 1] - req + 1);
  }
  if (k == 0) {
    s += '1';
    ans = 0;
    long long int cont = 0;
    for (i = 0; i < s.size(); i++) {
      if (s[i] == '1') {
        ans += ((cont * (cont + 1)) >> 1);
        cont = 0;
      } else
        cont++;
    }
  }
  cout << ans << endl;
  return 0;
}
