#include <bits/stdc++.h>
using namespace std;
int a[1000000];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long ans = 0;
  int n;
  cin >> n;
  string s;
  cin >> s;
  a[0] = 1;
  int check = 0;
  for (int i = 0; i < (int)s.length(); i++) {
    if (s[i] == '1') check++;
    if (check >= n) ans += a[check - n];
    a[check]++;
  }
  cout << ans << endl;
  return 0;
}
