#include <bits/stdc++.h>
using namespace std;
string second;
long long ans, lst;
int k, cnt;
int main() {
  cin >> k >> second;
  if (k == 0) {
    for (int i = 0; i < second.size(); i++)
      if (second[i] == '0') {
        int j = i;
        while (j < second.size() && second[j] == '0') j++;
        ans += 1LL * (j - i + 1) * (j - i) / 2;
        i = j - 1;
      }
    cout << ans;
    return 0;
  }
  int j = 0;
  for (int i = 0; i < second.size(); i++) {
    if (cnt < k) {
      if (j == second.size()) break;
      lst = 0;
      while (j < second.size() && cnt + second[j] - '0' <= k) {
        cnt += second[j] - '0';
        if (cnt == k) lst++;
        j++;
      }
      if (cnt != k) break;
      ans += lst;
    } else
      ans += lst;
    if (second[i] == '1' && cnt) cnt--;
  }
  cout << ans;
  return 0;
}
