#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 1;
int a[N];
int main() {
  long long ans = 0, ones = 0, k;
  string s;
  cin >> k >> s;
  a[0] = -1;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '1') ones++, a[ones] = i;
    if (ones >= k) {
      if (k != 0)
        ans += a[ones - k + 1] - a[ones - k];
      else if (s[i] == '0')
        ans += i - a[ones];
    }
  }
  cout << ans << endl;
}
