#include <bits/stdc++.h>
using namespace std;
int K, pos[1000010], cnt;
long long result;
string S;
int main() {
  cin >> K >> S;
  S = '1' + S + '1';
  for (int i = 0; i < S.size(); i++)
    if (S[i] == '1') {
      pos[cnt] = i;
      cnt++;
    }
  if (cnt - 2 < K)
    result = 0;
  else if (!K) {
    long long j = 0;
    for (int i = 0; i < S.size(); i++) {
      if (S[i] == '0')
        j++;
      else {
        result += j * (j + 1) / 2;
        j = 0;
      }
    }
  } else {
    int left = 1, right = left + K - 1;
    while (right < cnt - 1) {
      result += (long long)(pos[left] - pos[left - 1]) *
                (pos[right + 1] - pos[right]);
      left++;
      right++;
    }
  }
  cout << result << endl;
  return 0;
}
