#include <bits/stdc++.h>
using namespace std;
const long double pi = acos(-1);
long long a[1000002] = {};
long long b[1000002] = {};
string s = "", ss = "";
long long n, m, k, w;
long long ans;
long long mod = 1e9 + 7;
int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  int t = 1;
  while (t--) {
    cin >> m;
    cin >> s;
    n = s.size();
    ans = 0;
    vector<long long> v;
    v.push_back(0);
    for (long long i = 0; i < n; i++)
      if (s[i] - '0') v.push_back(i + 1);
    v.push_back(n + 1);
    if (v.size() - 2 < m) {
      cout << "0\n";
      continue;
    }
    if (!m) {
      long long c = 0;
      for (long long i = 0; i < n; i++) {
        if (s[i] == '0')
          c++;
        else {
          ans += c * (c + 1) / 2;
          c = 0;
        }
      }
      ans += c * (c + 1) / 2;
      cout << ans << "\n";
      continue;
    }
    for (long long i = 1; i < v.size() - 1; i++) {
      if (i + m >= v.size()) break;
      long long te = v[i] - v[i - 1] - 1;
      ans += te;
      ans++;
      long long te1 = v[i + m] - v[i + m - 1] - 1;
      ans += te1;
      ans += te * te1;
    }
    cout << ans << "\n";
  }
  return 0;
}
