#include <bits/stdc++.h>
using namespace std;
int k;
string s;
int main() {
  cin >> k >> s;
  long long ret = 0;
  int l = s.length();
  long long i, p = 0, a = 0, b = 0, j = 0;
  if (k) {
    for (i = 0; i < l; i++) {
      p = p + s[i] - '0';
      if (p == k) {
        a = 1;
        int tm = j;
        while (s[j] != '1') {
          j++;
          a++;
        }
        j = tm + a;
        b = 1;
        while (s[i + 1] != '1' && i + 1 < l) {
          b++;
          i++;
        }
        ret = ret + a * b;
        p--;
      }
    }
  } else {
    ret = 0;
    a = 0;
    for (i = 0; i < l; i++) {
      if (s[i] == '0')
        a++;
      else {
        ret = ret + a * (a + 1) / 2;
        a = 0;
      }
    }
    ret = ret + a * (a + 1) / 2;
  }
  cout << ret << endl;
}
