#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,fma")
using namespace std;
template <typename T>
using vc = vector<T>;
template <typename T>
using uset = unordered_set<T>;
template <typename A, typename B>
using umap = unordered_map<A, B>;
template <typename T, typename Comp = less<T>>
using pq = priority_queue<T, vc<T>, Comp>;
template <typename T>
using minpq = pq<T, greater<T>>;
using ld = long double;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using ppi = pair<pii, int>;
using pip = pair<int, pii>;
using vi = vc<int>;
using vii = vc<pii>;
constexpr char el = '\n';
constexpr char sp = ' ';
constexpr int INF = 0x3f3f3f3f;
constexpr ll LLINF = 0x3f3f3f3f3f3f3f3fLL;
int k;
string s;
vi a{-1};
ll evan(ll x) { return x * (x + 1) / 2; }
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed;
  cin >> k >> s;
  for (int i = 0; i < s.size(); ++i)
    if (s[i] == '1') a.push_back(i);
  a.push_back(s.size());
  ll ans = 0;
  if (k == 0) {
    for (int i = 1; i < a.size(); ++i) ans += evan(a[i] - a[i - 1] - 1);
    cout << ans;
    exit(0);
  }
  int l = 1, r = k;
  while (r + 1 < a.size()) {
    ll A = a[l] - a[l - 1];
    ll B = a[r + 1] - a[r];
    ans += A * B;
    ++l, ++r;
  }
  cout << ans;
}
