#include <bits/stdc++.h>
using namespace std;
string vow = "aeiou";
const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
const long double pie = 3.14159265358979;
const long long mod = 1e9 + 7;
void solve(int test_case) {
  int k;
  cin >> k;
  string s;
  cin >> s;
  int n = s.size();
  vector<int> pref(n + 1);
  for (int i = 1; i < n + 1; i++) pref[i] = pref[i - 1] + s[i - 1] - '0';
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int x = pref[i + 1];
    int val = x - k;
    if (val < 0) continue;
    ;
    int ans_indx = -1;
    for (int lo = 0, hi = i; lo <= hi;) {
      int mid = lo + hi >> 1;
      if (pref[mid] > val)
        hi = mid - 1;
      else if (pref[mid] == val)
        ans_indx = mid, hi = mid - 1;
      else
        lo = mid + 1;
    }
    if (ans_indx == -1) continue;
    ;
    long long L = ans_indx;
    ans_indx = -1;
    for (int lo = 0, hi = i; lo <= hi;) {
      int mid = lo + hi >> 1;
      if (pref[mid] == val)
        ans_indx = mid, lo = mid + 1;
      else if (pref[mid] < val)
        lo = mid + 1;
      else
        hi = mid - 1;
    }
    if (ans_indx == -1) continue;
    ;
    long long R = ans_indx;
    ans += R - L + 1;
  }
  cout << ans;
  cout << "\n";
}
int main() {
  int t = 1;
  for (int i = 0; i < t; i++) solve(i);
  return 0;
}
