#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int main() {
  ios::sync_with_stdio(false);
  string s;
  int k, n;
  cin >> k >> s;
  n = (int)s.size();
  long long res = 0;
  if (k) {
    int c = 0, st = -1;
    for (int i = (0); i < (n); i++) {
      if (s[i] == '1') {
        if (st == -1) st = i;
        c++;
      }
      if (c == k) {
        int l = st - 1, r = i + 1;
        long long c1 = 0, c2 = 0;
        while (l >= 0 && s[l] == '0') l--, c1++;
        while (r < n && s[r] == '0') r++, c2++;
        st++;
        while (st < n && s[st] == '0') st++;
        res += (c1 + 1) * (c2 + 1);
        i = r - 1;
        c--;
      }
    }
  } else {
    long long c = 0;
    for (int i = (0); i < (n); i++) {
      if (s[i] == '0')
        c++;
      else
        res += c * (c + 1) / 2, c = 0;
    }
    res += c * (c + 1) / 2;
  }
  cout << res << endl;
  return 0;
}
