#include <bits/stdc++.h>
using namespace std;
long long front[1000001], back[1000001], vt[1000001];
int main() {
  long long k, sz, ko = 0, j = 0, kq = 0;
  string s;
  cin >> k >> s;
  sz = s.size();
  s = " " + s;
  for (long long i = 1; i <= sz + 1; i++) {
    front[i] = ko;
    if (s[i] == '0')
      ko++;
    else
      ko = 0;
  }
  ko = 0;
  for (long long i = sz; i >= 1; i--) {
    back[i] = ko;
    if (s[i] == '0')
      ko++;
    else
      ko = 0;
  }
  for (long long i = 1; i <= sz; i++)
    if (s[i] == '1') j++, vt[j] = i;
  if (k == 0) {
    vt[j + 1] = sz + 1;
    front[sz + 1] = ((s[sz] == '1') ? 0 : front[sz] + 1);
    j++;
    for (long long i = 1; i <= j; i++)
      kq += front[vt[i]] * (front[vt[i]] + 1) / 2;
    cout << kq;
    return 0;
  }
  for (long long i = 1; i <= j - k + 1; i++)
    kq += (front[vt[i]] + 1) * (back[vt[i + k - 1]] + 1);
  cout << kq;
}
