#include <bits/stdc++.h>
using namespace std;
map<long long int, long long int> m1, m2;
map<long long int, long long int>::iterator itr, itr1, itr2;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int k;
  cin >> k;
  string str;
  cin >> str;
  vector<long long int> v;
  for (long long int i = 0; i < str.size(); i++) {
    if (str[i] == '1') v.push_back(i);
  }
  long long int ans = 0;
  if (k == 0) {
    long long int count = 0;
    for (long long int i = 0; i < str.size(); i++) {
      if (str[i] == '0')
        count++;
      else {
        ans += count;
        ans += (count * (count - 1)) / 2;
        count = 0;
      }
    }
    if (count != 0) {
      ans += count;
      ans += (count * (count - 1)) / 2;
    }
    cout << ans << endl;
  } else {
    if (v.size() < k)
      cout << "0" << endl;
    else {
      long long int left = 0;
      long long int right = k - 1;
      while (right < v.size()) {
        long long int sum = 1;
        if (left == 0)
          sum *= (v[left] + 1);
        else
          sum *= (v[left] - v[left - 1]);
        if (right == v.size() - 1)
          sum *= (str.size() - v[right]);
        else
          sum *= (v[right + 1] - v[right]);
        ans += sum;
        left++;
        right++;
      }
      cout << ans << endl;
    }
  }
}
