#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> add_pair(pair<long long, long long> a,
                                    pair<long long, long long> b) {
  return make_pair(a.first + b.first, a.second + b.second);
}
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
  return a.first < b.first;
}
long long power(long long a, long long b) {
  long long res = 1;
  a = a % (long long)1e9 + 7;
  while (b > 0) {
    if (b & 1) {
      res = (res * a) % (long long)1e9 + 7;
      b--;
    }
    a = (a * a) % (long long)1e9 + 7;
    b = b >> 1;
  }
  return res;
}
long long fermat_inv(long long y) { return power(y, (long long)1e9 + 7 - 2); }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, i, k, cnt, start, end, l, r;
  string s;
  cin >> k >> s;
  n = s.length();
  vector<long long> a;
  a.reserve(n);
  for (i = 0; i < n; i += 1) {
    if (s[i] == '1') a.push_back(i);
  }
  if (k == 0) {
    if (a.empty()) {
      cout << ((n + 1) * n) / 2 << '\n';
      return 0;
    }
    l = 0;
    cnt = 0;
    for (i = 0; i < a.size(); i += 1) {
      r = a[i];
      cnt += ((r - l + 1) * (r - l)) / 2;
      l = r + 1;
    }
    if (l != n) cnt += ((n - l) * (n - l + 1)) / 2;
    cout << cnt << '\n';
    return 0;
  }
  if ((k != 0 && a.empty()) || k > a.size()) {
    cout << 0 << '\n';
    return 0;
  }
  start = cnt = 0;
  for (i = 0; i < a.size() - k + 1; i += 1) {
    l = a[i];
    r = a[i + k - 1];
    end = (i == a.size() - k) ? n - 1 : a[i + k] - 1;
    cnt += (l - start + 1) * (end - r + 1);
    start = l + 1;
  }
  cout << cnt << '\n';
  return 0;
}
