#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int x;
  cin >> x;
  string s;
  cin >> s;
  int n = s.size();
  vector<long long> sum(n + 1);
  for (int i = 0; i < n; i++) {
    if (s[i] == '1')
      sum[i + 1] = sum[i] + 1;
    else
      sum[i + 1] = sum[i];
  }
  if (x == 0) {
    int count_0 = 0;
    long long counter = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] == '0') {
        ++count_0;
      } else {
        count_0 = 0;
      }
      counter += count_0;
    }
    cout << counter << endl;
  } else {
    long long counter = 0;
    for (int i = 0; i < n; i++) {
      vector<long long>::iterator it_h =
          upper_bound(sum.begin(), sum.end(), sum[i] + x);
      vector<long long>::iterator it_l =
          lower_bound(sum.begin(), sum.end(), sum[i] + x);
      counter += (it_h - it_l);
    }
    cout << counter << endl;
  }
}
