#include <bits/stdc++.h>
using namespace std;
long long sum(long long x) {
  long long y = 0;
  for (long long i = 1; i <= x; i++) y += i;
  return y;
}
int main() {
  long long x, ptr = 0, ones = 0, beforeZeros = 0, afterZeros = 0, res = 0;
  string y;
  cin >> x >> y;
  if (x == 0) {
    while (ptr < y.size()) {
      long long z = 0;
      while (y[ptr] == '0') {
        z++;
        ptr++;
      }
      ptr++;
      res += sum(z);
    }
    cout << res << endl;
  } else {
    vector<long long> BZ;
    vector<long long> AZ;
    long long z = 0;
    long long One = 0;
    while (ptr < y.size()) {
      if (y[ptr] == '0') z++;
      if (y[ptr] == '1') {
        One++;
        BZ.push_back(z);
        if (One > x) {
          AZ.push_back(z);
        }
        z = 0;
      }
      ptr++;
    }
    AZ.push_back(z);
    if (One >= x) {
      for (int i = 0; i < AZ.size(); i++) {
        res += 1 + AZ[i] + BZ[i] + (BZ[i] * AZ[i]);
      }
      cout << res << endl;
    } else
      cout << '0' << endl;
  }
  return 0;
}
