#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int MD = 1e9 + 7;
int main() {
  int k;
  cin >> k;
  string s;
  cin >> s;
  int pointer1 = -1, pointer2 = -1, ones = 0;
  long long ans = 0;
  if (k == 0) {
    int j = 0;
    for (int i = 0; i < (int)s.size(); ++i) {
      if (s[i] == '0') {
        j = max(i, j);
        while (j < s.size() && s[j] == '0') j++;
        ans += j - i;
        j--;
      }
    }
    cout << ans;
    return 0;
  }
  for (int i = 0; i < (int)s.size(); i++) {
    pointer1 = max(i, pointer1 + 1);
    while (pointer1 < s.size() && ones < k) {
      ones += (s[pointer1] == '1');
      pointer1++;
    }
    pointer1 -= 1;
    pointer2 = max(pointer1 + 1, pointer2);
    while (pointer2 < s.size() && s[pointer2] == '0') pointer2++;
    if (ones == k) {
      ans += pointer2 - pointer1;
    }
    pointer2 -= 1;
    ones -= (s[i] == '1');
  }
  cout << ans;
  return 0;
}
