#include <bits/stdc++.h>
using namespace std;
const int N = 1E6 + 5;
vector<long long> v1(N);
int main() {
  ifstream ff("file.txt");
  int k;
  cin >> k;
  string s1;
  cin >> s1;
  s1 = '0' + s1;
  long long answer = 0;
  set<long long> s;
  long long y = -1;
  if (k == 0) {
    long long kol = 0;
    for (int i = 1; i < s1.length(); i++) {
      if (s1[i] == '0') {
        kol++;
      } else {
        answer += kol * (kol + 1) / 2;
        kol = 0;
      }
    }
    if (kol != 0) {
      answer += kol * (kol + 1) / 2;
    }
    cout << answer << endl;
    return 0;
  }
  for (int i = 1; i < s1.length(); i++) {
    v1[i] = v1[i - 1];
    if (s1[i] == '1') {
      v1[i]++;
      s.insert(i);
      if (v1[i] == k && y == -1) {
        y = i;
      }
    }
  }
  if (y == -1) {
    cout << 0 << endl;
    return 0;
  }
  s.insert(s1.length() + 1);
  set<long long>::iterator p = s.begin(), p1, p2;
  p1 = s.find(y);
  long long kkol = 1;
  long long answ1, answ2;
  long long help = 0;
  for (p1, p; *p1 != s1.length() + 1; p1++, p++) {
    answ1 = *p - kkol;
    kkol = *p + 1;
    p2 = p1;
    p2++;
    if (*p2 == s1.length() + 1) {
      help = 1;
    }
    answ2 = (*p2 - help - *p1) - 1;
    answer += 1 + (answ1 + answ2) + (answ1 * answ2);
  }
  cout << answer << endl;
  return 0;
}
