#include <bits/stdc++.h>
using namespace std;
const long long nmax = 1e6 + 5;
long long cnt[nmax];
int main() {
  long long k, n;
  string s;
  cin >> k;
  cin >> s;
  n = s.size();
  long long sum = 0, ans = 0;
  cnt[0]++;
  for (long long i = 0; i < n; ++i) {
    sum += s[i] - '0';
    if (sum - k >= 0) ans += cnt[sum - k];
    cnt[sum]++;
  }
  cout << ans << '\n';
}
