#include <bits/stdc++.h>
using namespace std;
int main() {
  int n = 0, i = 0;
  long long int cuenta = 0;
  string s = "";
  scanf("%d\n", &n);
  cin >> s;
  int tam = s.length();
  int mat[tam + 1];
  int rec[tam + 1];
  mat[0] = 0;
  rec[0] = 0;
  for (i = 0; i < s.length(); i++) {
    mat[i + 1] = mat[i] + (s[i] - '0');
    rec[i + 1] = 0;
  }
  for (i = 0; i <= tam; i++) {
    if (mat[i] - n >= 0) cuenta += rec[mat[i] - n];
    rec[mat[i]]++;
  }
  cout << cuenta << endl;
  return 0;
}
