#include <bits/stdc++.h>
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
const long double PI = acos(-1.0);
bool AreSame(long double a, long double b) { return fabs(a - b) < 1e-9; }
long long int power(long long int x, long long int y) {
  long long int res = 1;
  x = x;
  while (y > 0) {
    if (y & 1) res = (res * x);
    y = y >> 1;
    x = (x * x);
  }
  return res;
}
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long int ceil2(long long int a, long long int b) {
  long long int c = a / b;
  if (a % b) c++;
  return c;
}
bool isPalindrome(string s) {
  string t = s;
  reverse(t.begin(), t.end());
  return s == t;
}
long long int lowerIndex(vector<long long int> &arr, long long int x) {
  long long int n = arr.size();
  long long int l = 0, h = n - 1;
  while (l <= h) {
    long long int mid = (l + h) / 2;
    if (arr[mid] >= x)
      h = mid - 1;
    else
      l = mid + 1;
  }
  return l;
}
long long int upperIndex(vector<long long int> &arr, long long int y) {
  long long int n = arr.size();
  long long int l = 0, h = n - 1;
  while (l <= h) {
    long long int mid = (l + h) / 2;
    if (arr[mid] <= y)
      l = mid + 1;
    else
      h = mid - 1;
  }
  return h;
}
long long int countInRange(vector<long long int> &arr, long long int x,
                           long long int y) {
  long long int n = arr.size();
  long long int count = 0;
  count = upperIndex(arr, y) - lowerIndex(arr, x) + 1;
  return count;
}
void solve() {
  long long int k;
  cin >> k;
  string s;
  cin >> s;
  if (k == 0) {
    vector<long long int> temp;
    s.push_back('?');
    string t;
    t.push_back(s[0]);
    for (long long int i = 1; i < s.length(); i++) {
      if (s[i] == s[i - 1])
        t.push_back(s[i]);
      else {
        if (t[0] == '0') temp.push_back(t.length());
        t.clear();
        t.push_back(s[i]);
      }
    };
    long long int res = 0;
    for (int i = 0; i < temp.size(); i++)
      res = res + (temp[i] * (temp[i] - 1)) / 2 + temp[i];
    cout << res << "\n";
    return;
  }
  vector<long long int> v, v0;
  v.push_back(-1);
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '1')
      v.push_back(i);
    else
      v0.push_back(i);
  }
  v.push_back(LLONG_MAX);
  long long int res = 0;
  for (long long int i = 1; i < v.size() - 1; i++) {
    if (i + k - 1 >= v.size() - 1) break;
    long long int start = v[i], end = v[i + k - 1];
    long long int pre = 1, suff = 1;
    long long int t1 = v[i - 1], t2 = v[i + k];
    pre = countInRange(v0, v[i - 1], start);
    suff = countInRange(v0, end, t2);
    ;
    res = res + (pre + 1) * (suff + 1);
  }
  cout << res << "\n";
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
