#include <bits/stdc++.h>
using namespace std;
int main() {
  int k;
  cin >> k;
  string in;
  getline(cin, in);
  getline(cin, in);
  long long res = 0;
  int i = 0, j = 0;
  long long trailing, leading;
  int count = 0;
  while (i < in.size() && count < k) {
    if (in[i] == '1') count++;
    i++;
  }
  if (count < k) {
    cout << 0 << endl;
    return 0;
  }
  while (i <= in.size()) {
    leading = trailing = 0;
    while (j < in.size() && in[j] == '0') {
      leading++;
      j++;
    }
    while (i < in.size() && in[i] == '0') {
      trailing++;
      i++;
    }
    ++j;
    ++i;
    if (k)
      res += (leading + 1) * (trailing + 1);
    else
      for (long long x = 1; x <= leading; x++) res += x;
  }
  cout << res << endl;
  return 0;
}
