#include <bits/stdc++.h>
int take() {
  int n;
  scanf("%d", &n);
  return n;
}
double ttake() {
  double n;
  scanf("%lf", &n);
  return n;
}
long long takes() {
  long long n;
  scanf("%lld", &n);
  return n;
}
int cas;
using namespace std;
bool approximatelyEqual(float a, float b, float epsilon) {
  return fabs(a - b) <= ((fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}
bool essentiallyEqual(float a, float b, float epsilon) {
  return fabs(a - b) <= ((fabs(a) > fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}
bool definitelyGreaterThan(float a, float b, float epsilon) {
  return (a - b) > ((fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}
bool definitelyLessThan(float a, float b, float epsilon) {
  return (b - a) > ((fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}
int main() {
  int tc = 1;
  while (tc--) {
    int k = take();
    long long ans = 0;
    string s;
    cin >> s;
    int l = 0, r = 0, cur = 0, add = 0;
    long long zero = 0;
    while (l < s.size()) {
      r = max(l, r);
      if (l == r) add = 0, cur = 0;
      while (r < s.size()) {
        int d = cur;
        cur += (s[r] - 48);
        if (cur > k) {
          cur--;
          break;
        }
        if (cur == k) add++;
        if (k == 0) zero += add;
        r++;
      }
      if (cur >= k && l != r) ans += add;
      cur -= (s[l] - 48);
      if (cur < k) add = 0;
      l++;
    }
    if (k == 0) ans = zero;
    cout << ans << "\n";
  }
  { return 0; };
}
