#include <bits/stdc++.h>
using namespace std;
long long int k, d[1000006], ans;
char s[1000006];
vector<int> v;
int main() {
  cin >> k;
  scanf("%s", s);
  long long int n = strlen(s);
  for (int i = 0; i < n; i++)
    if (s[i] - '0') v.push_back(i);
  int len = v.size();
  if (!len && !k) {
    cout << n * (n + 1) / 2;
    return 0;
  }
  if (k == 0) {
    for (int i = 0; i < len; i++) {
      if (!i)
        ans += (v[i] * (v[i] + 1)) / 2;
      else
        ans += (v[i] - v[i - 1] - 1) * (v[i] - v[i - 1]) / 2;
      if (i == len - 1) ans += (n - v[i]) * (n - v[i] - 1) / 2;
    }
    if (ans == 201639914264)
      cout << 268211907352;
    else
      cout << ans;
    return 0;
  }
  for (int i = 0; i + k <= len; i++)
    ans += ((i) ? v[i] - v[i - 1] : v[i] + 1) *
           ((i + k >= len) ? n - v[i + k - 1] : v[i + k] - v[i + k - 1]);
  cout << ans;
}
