#include <bits/stdc++.h>
using namespace std;
long long startt = 0;
long long endd = 0;
long long ones = 0;
long long ones_pos[1000009];
long long ind = 0;
string strok;
long long len;
long long k;
long long n;
long long summ = 0;
void colib() {
  endd = k - 1;
  startt = 0;
}
void work() {
  while (startt + k - 1 < ind) {
    long long summ1 = 0;
    long long summ2 = 0;
    if (startt == 0) {
      summ1 = ones_pos[startt] + 1;
    } else
      summ1 = ones_pos[startt] - ones_pos[startt - 1];
    if (startt + k - 1 == ind - 1) {
      summ2 = len - ones_pos[startt + k - 1];
    } else
      summ2 = ones_pos[startt + k] - ones_pos[startt + k - 1];
    summ += summ1 * summ2;
    startt++;
  }
}
int main() {
  cin >> k;
  cin >> strok;
  len = strok.length();
  for (long long i = 0; i < len; i++) {
    if (strok[i] == '1') {
      ones_pos[ind++] = i;
    }
  };
  if (k == 0) {
    ones_pos[ind++] = len;
    for (long long i = 0; i < ind; i++) {
      if (i == 0)
        n = ones_pos[i];
      else
        n = ones_pos[i] - ones_pos[i - 1] - 1;
      summ += n * (n - 1) / 2 + n;
    }
    cout << summ;
    exit(0);
  }
  startt = endd = 0;
  colib();
  work();
  cout << summ;
}
