#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t, n, a, b, c, q, m, k, d;
  cin >> k;
  string s;
  cin >> s;
  vector<int> vec;
  vec.emplace_back(-1);
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '1') {
      vec.emplace_back(i);
    }
  }
  int one = s[0] == '1' ? 1 : 0;
  vector<long long int> dp(s.length(), 0);
  if (s[0] == '1' && k == 1) {
    dp[0] = 1;
  } else {
    dp[0] = 0;
  }
  if (k == 0) {
    dp[0] = 0;
    int len = 0;
    for (int i = 0; i < s.length(); i++) {
      if (s[i] == '0') {
        len++;
        dp[i] += len;
      } else {
        len = 0;
      }
    }
    cout << accumulate(dp.begin(), dp.end(), (long long)0) << "\n";
    return 0;
  }
  for (int i = 1; i < s.length(); i++) {
    if (s[i] == '1') {
      one++;
      if (one >= k) {
        dp[i] = vec[one - k + 1] - vec[one - k];
      } else
        dp[i] = dp[i - 1];
    } else {
      dp[i] = dp[i - 1];
    }
  }
  cout << accumulate(dp.begin(), dp.end(), (long long)0) << "\n";
  return 0;
}
