#include <bits/stdc++.h>
using namespace std;
struct Node {
  long long l, r;
} num[1000005];
char s[1000005];
int v[1000005];
int main() {
  int n, i, j;
  ios::sync_with_stdio(false);
  cin >> n;
  cin >> s;
  long long cont = 0, ans = 0, tcont = 0;
  int l = strlen(s);
  if (n == 0) {
    for (int i = 0; i < l; i++) {
      if (s[i] == '0')
        cont++;
      else {
        ans += cont * (cont + 1) / 2;
        cont = 0;
      }
    }
    if (s[i] == '0')
      ;
    ans += cont * (cont + 1) / 2;
    printf("%I64d\n", ans);
  } else {
    for (int i = 0; i < l; i++) {
      if (s[i] == '1' && i == 0) {
        num[i].l = 0;
        v[tcont++] = i;
        cont = 0;
      } else if (s[i] == '0' && i == l - 1) {
        cont++;
        num[v[tcont - 1]].r = cont;
        cont = 0;
      } else if (s[i] == '1') {
        num[i].l = cont;
        num[v[tcont - 1]].r = cont;
        v[tcont++] = i;
        cont = 0;
        if (i == l - 1) num[i].r = 0;
      } else {
        cont++;
      }
    }
    int u = n - 1;
    for (int i = 0; i < tcont; i++) {
      if (i + u >= tcont) break;
      ans += (num[v[i]].l + 1) * (num[v[i + u]].r + 1);
    }
    printf("%I64d\n", ans);
  }
}
