#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int k;
  cin >> k;
  string str;
  cin >> str;
  int j = 0, i = 0;
  int n = str.size();
  long long cnt = 0;
  long long ans = 0;
  if (k == 0) {
    for (int i = 0; i < n; i++) {
      if (str[i] == '0')
        cnt++;
      else {
        ans += (cnt * (cnt + 1)) / 2;
        cnt = 0;
      }
    }
    ans += (cnt * (cnt + 1)) / 2;
    cout << ans;
    return 0;
  }
  while (i < n) {
    if (str[i] == '1') cnt++;
    if (cnt == k) {
      long long l0 = 0, e0 = 0;
      while (str[j] == '0') {
        l0++;
        j++;
      }
      j++;
      i++;
      while (i < n && str[i] == '0') {
        e0++;
        i++;
      }
      i--;
      cnt -= 1;
      ans += (e0 + 1) * (l0 + 1);
    }
    i++;
  }
  cout << ans;
  return 0;
}
