#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int k;
  cin >> k;
  string s;
  cin >> s;
  long long int res = 0, mok = 0, tot = 0, res1 = 0, x = 0, len, som = 0;
  len = s.length();
  long long int a[len + 1];
  for (int i = 0; i <= len; i++) a[i] = 0;
  for (int i = 0; i < len; i++) {
    if (s[i] == '1') {
      a[x] = i + 1;
      x++;
    }
  }
  long long int aft[x + 1];
  long long int bef = a[0] - 1;
  aft[x] = len - a[x - 1];
  for (int i = 1; i < x; i++) {
    aft[i] = a[i] - a[i - 1] - 1;
  }
  aft[0] = bef;
  if (k > x)
    cout << 0;
  else if (k == 0) {
    if (x == 0) {
      mok = ((len * (len + 1)) / 2);
      cout << mok;
    } else {
      for (int i = 0; i <= x; i++) {
        res += (aft[i] * (aft[i] + 1)) / 2;
      }
      cout << res;
    }
  } else {
    for (int j = 1; j <= (x - k + 1); j++) {
      res1 = aft[j - 1] + 1;
      res = aft[k + som] * res1;
      tot += res + res1;
      som++;
    }
    cout << tot;
  }
}
