#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long test, i, j, xy, flag = 0, n, u, count, d, o1 = 0, o2 = 0, s, e, l,
                            r, x, y, m, z, max1, x1, y1, k, x2, y2, z1, sum, f,
                            min1;
  string a;
  cin >> k >> a;
  max1 = 0;
  n = a.size();
  long long prefix[n], suffix[n];
  memset(prefix, 0, sizeof prefix);
  memset(suffix, 0, sizeof suffix);
  count = 0;
  for (i = 0; i < n; i++) {
    if (k == 0 && a[i] == '1') {
      max1 += ((count * (count + 1)) / 2);
    }
    if (a[i] == '0') {
      count++;
    } else {
      count = 0;
    }
    prefix[i] = count;
  }
  if (k == 0) {
    cout << max1 + ((count * (count + 1)) / 2) << "\n";
    return 0;
  }
  count = 0;
  for (i = n - 1; i >= 0; i--) {
    if (a[i] == '0') {
      count++;
    } else {
      count = 0;
    }
    suffix[i] = count;
  }
  count = 0;
  deque<long long> mk;
  for (i = 0; i < n; i++) {
    if (a[i] == '1') {
      mk.push_back(i);
      while (mk.size() > k) {
        mk.pop_front();
      }
      if (mk.size() == k) {
        x = y = 0;
        x = mk.front();
        y = mk.back();
        x = max(0LL, x - 1);
        y = min(n - 1, y + 1);
        count += suffix[y] + prefix[x] + (suffix[y] * prefix[x]) + 1;
      }
    }
  }
  cout << count << "\n";
  return 0;
}
