#include <bits/stdc++.h>
using namespace std;
int pref[1000005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long z;
  cin >> z;
  string a;
  cin >> a;
  string s = "a";
  a = s + a;
  for (int q = 1; q < a.size(); q++) {
    pref[q] = pref[q - 1];
    if (a[q] == '1') pref[q]++;
  }
  long long low, mid, high, temp1, temp2;
  long long ans = 0;
  long long cnt;
  for (int q = 1; q < a.size(); q++) {
    low = q;
    high = a.size() - 1;
    temp1 = temp2 = -1;
    while (low <= high) {
      mid = (low + high) / 2;
      cnt = pref[mid] - pref[q - 1];
      if (cnt > z) {
        high = mid - 1;
      } else if (cnt < z)
        low = mid + 1;
      else {
        temp1 = mid;
        high = mid - 1;
      }
    }
    low = q;
    high = a.size() - 1;
    while (low <= high) {
      mid = (low + high) / 2;
      cnt = pref[mid] - pref[q - 1];
      if (cnt > z) {
        high = mid - 1;
      } else if (cnt < z)
        low = mid + 1;
      else {
        temp2 = mid;
        low = mid + 1;
      }
    }
    if (temp1 != -1) {
      ans += (temp2 - temp1 + 1);
    }
  }
  cout << ans << endl;
}
