#include <bits/stdc++.h>
using namespace std;
int a[1000005];
queue<long long int> q;
vector<long long int> v;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int i, j, k, n, m, mid;
  cin >> k;
  string s;
  cin >> s;
  n = s.size();
  int co = 0;
  long long int sum = 0;
  if (k == 0) {
    for (i = 0; i < n; i++) {
      if (s[i] == '0') {
        co++;
      } else
        co = 0;
      sum += (co);
    }
    cout << sum;
    return 0;
  }
  for (i = 0; i < n; i++) {
    if (s[i] == '1') {
      a[i] = co;
      co = 0;
      v.push_back(i);
    } else
      co++;
  }
  long long int first = 0;
  long long int l = v.size();
  for (i = k - 1; i < l; i++) {
    long long int temp1 = a[v[first]] + 1;
    long long int temp2;
    if (i + 1 < l)
      temp2 = v[i + 1] - v[i];
    else
      temp2 = n - v[i];
    sum += temp1 * temp2;
    first++;
  }
  cout << sum;
  return 0;
}
