#include <bits/stdc++.h>
using namespace std;
int main() {
  int k;
  while (cin >> k) {
    vector<int> one;
    vector<int> zero;
    string s;
    cin >> s;
    long long ans = 0;
    long long cnt1 = 0, cnt0 = 0;
    bool flag = 0;
    int len = s.length();
    for (int i = 0; i < len; i++) {
      if (s[i] == '1')
        one.push_back(i);
      else
        zero.push_back(i);
    }
    if (k == 0) {
      long long cnt = 0;
      for (int i = 0; i < len; i++) {
        if (s[i] == '0') {
          cnt++;
        } else {
          ans += (1LL * (cnt * (cnt + 1))) / 2;
          cnt = 0;
        }
      }
      if (cnt) ans += (1LL * (cnt * (cnt + 1))) / 2;
      cout << ans << endl;
      continue;
    }
    int l = 0, temp = 0;
    for (int i = 0; i < one.size(); i++) {
      temp++;
      if (temp == k) {
        long long a, b;
        if (l > 0)
          a = one[l] - one[l - 1] - 1;
        else
          a = one[l];
        if (i + 1 < one.size())
          b = one[i + 1] - one[i] - 1;
        else
          b = len - one[i] - 1;
        ans += (long long)(a + b + a * b + 1);
        l++;
        temp--;
      }
    }
    cout << ans << endl;
  }
}
