#include <bits/stdc++.h>
int main() {
  char buf[1000002];
  int k;
  while (scanf("%d %s", &k, buf) == 2) {
    long long int count = 0, sum = 0;
    if (!k) {
      char *start = NULL;
      for (start = buf; *start == '0'; ++start)
        ;
      count = start - buf + 1;
      sum += (count * (count - 1)) >> 1;
      while (*start) {
        char *temp = start;
        for (++start; *start == '0'; ++start)
          ;
        count = start - temp;
        sum += (count * (count - 1)) >> 1;
      }
      printf("%I64d\n", sum);
    } else {
      char *start = NULL, *end = NULL, *temp = NULL;
      for (start = buf; *start == '0'; ++start)
        ;
      for (end = start; *end != '\0' && count < k; ++end)
        if (*end == '1') ++count;
      if (count < k)
        puts("0");
      else {
        count = start - buf + 1;
        --end;
        do {
          temp = end;
          for (++end; *end == '0'; ++end)
            ;
          sum += count * (end - temp);
          temp = start;
          for (++start; *start == '0'; ++start)
            ;
          count = start - temp;
        } while (*end);
        printf("%I64d\n", sum);
      }
    }
  }
  return 0;
}
