#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  t = 1;
  while (t--) {
    long long int n, m;
    cin >> m;
    string s;
    cin >> s;
    n = s.size();
    long long int a[n];
    long long int b[n];
    long long int ans = 0;
    a[0] = 0;
    b[n - 1] = n - 1;
    for (long long int i = 1; i < s.size(); i += 1) {
      if (s[i - 1] == '1') {
        a[i] = i;
      } else
        a[i] = a[i - 1];
    }
    for (int i = n - 2; i >= 0; i--) {
      if (s[i + 1] == '1')
        b[i] = i;
      else
        b[i] = b[i + 1];
    }
    long long int l = 0, r = 0, tmp = 0;
    std::vector<int> v;
    if (m != 0) {
      for (long long int i = 0; i < s.size(); i += 1) {
        if (s[i] == '1') {
          tmp += 1;
          v.push_back(i);
        }
        if (tmp == m and m != 0) {
          long long int t1 = v[l] - a[v[l]];
          long long int t2 = b[v[v.size() - 1]] - v[v.size() - 1];
          ans += 1;
          ans += t1;
          ans += t2;
          ans += t1 * t2;
          l += 1;
          tmp -= 1;
        }
      }
    } else {
      long long int tmp = 0;
      for (long long int i = 0; i < s.size(); i += 1) {
        if (s[i] == '1') {
          ans += (tmp * (tmp + 1)) / 2;
          tmp = 0;
          continue;
        }
        tmp += 1;
      }
      ans += (tmp * (tmp + 1)) / 2;
    }
    cout << ans;
  }
  return 0;
}
