#include <bits/stdc++.h>
using namespace std;
const int N = 6100 + 5, mod = 31011;
int n, t, c, m, forests, mem[N][N];
long long ans;
vector<int> parent, rank1, arr2;
vector<pair<int, pair<int, int> > > soso;
vector<pair<int, int> > vec;
string second, s2;
bool compare(int a, int b) { return a > b; }
int solve(int i, int j) {
  if (i == second.size() || j == s2.size()) return 0;
  int &ret = mem[i][j];
  if (ret != -1) return ret;
  if (second[i] == s2[j]) return ret = solve(i + 1, j + 1) + 1;
  int choice1 = solve(i + 1, j);
  int choice2 = solve(i, j + 1);
  ret = max(choice1, choice2);
  return ret;
}
int main() {
  cin >> n >> second;
  long long before = 1, after = 1, kam = 0, bk = 0, kam2 = 0, ans2 = 0, b = 0;
  for (int i = 0; i < second.size(); ++i) {
    if (second[i] == '0')
      b++;
    else {
      ans2 += ((b + 1) * b) / 2;
      b = 0;
    }
  }
  ans2 += ((b + 1) * b / 2);
  for (int i = 0; i < second.size(); ++i) {
    if (second[i] == '1') kam++, kam2++;
    if (kam > n) {
      while (second[bk] == '0' && bk < i) before++, bk++;
      if (second[bk] == '1') bk++;
      ans += (before * after);
      after = 1, before = 1;
      kam--;
    }
    if (kam == n && second[i] == '0') after++;
  }
  while (second[bk] == '0' && bk < second.size()) before++, bk++;
  ans += (before * after);
  after = 1, before = 1;
  cout << (n == 0 ? ans2 : kam2 >= n ? ans : 0) << endl;
}
