#include <bits/stdc++.h>
using namespace std;
const int N = 5000006;
int k;
string s;
int pos[N];
int cT[N], cP[N];
int n;
int v[N];
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> k >> s;
  n = s.size();
  if (k == 0) {
    s = '1' + s;
    int i = 0;
    long long res = 0;
    while (i <= n) {
      int j = i;
      while (j < n && s[j + 1] == '0') j++;
      int cnt = j - i;
      res += 1ll * (cnt) * (cnt + 1) / 2;
      i = j + 1;
    }
    cout << res;
    return 0;
  }
  int cur = 0;
  memset(pos, -1, sizeof(pos));
  for (int i = 0; i < n; i++) {
    cur += (s[i] == '1');
    if (s[i] == '1') pos[cur] = i;
    v[i] = cur;
  }
  for (int i = 0; i < n; i++)
    if (s[i] == '1') {
      int cnt = 0;
      for (int j = i - 1; j >= 0; j--)
        if (s[j] == '0')
          cnt++;
        else
          break;
      cT[i] = cnt;
      cnt = 0;
      for (int j = i + 1; j < n; j++)
        if (s[j] == '0')
          cnt++;
        else
          break;
      cP[i] = cnt;
    }
  long long res = 0;
  for (int i = 0; i < n; i++)
    if (s[i] == '1') {
      int nx = pos[v[i] + k - 1];
      if (nx != -1) {
        res += 1ll * cT[i] * cP[nx] + cT[i] + cP[nx] + 1;
      }
    }
  cout << res;
  return 0;
}
