#include <bits/stdc++.h>
using namespace std;
const int MOD = pow(10, 9) + 7;
int main() {
  ios_base::sync_with_stdio(false);
  int k;
  cin >> k;
  string s;
  cin >> s;
  int n = s.length();
  int l = 0, r = 0;
  long long ans = 0LL;
  long long count1 = 0;
  while (l < n && k != 0) {
    long long countL = 0, countr = 0;
    bool found = false;
    while (r < n) {
      if (s[r] == '1') count1++;
      r++;
      if (count1 == k) {
        found = true;
        break;
      }
    }
    while (r < n && s[r] != '1') {
      countr++;
      r++;
    }
    while (l < n && s[l] != '1') {
      countL++;
      l++;
    }
    if (found) ans += (countL + 1) * (countr + 1);
    count1--;
    l++;
  }
  long long z = 0LL;
  if (k == 0) {
    for (int i = 0; i < n; i++) {
      if (s[i] == '0')
        z++;
      else {
        ans += (z * (z + 1)) / 2;
        z = 0;
      }
    }
  }
  cout << (ans + (z * (z + 1)) / 2);
  cout << endl;
  return 0;
}
