#include <bits/stdc++.h>
using namespace std;
char s[1111111];
int cnt[1111111], pos[1111111];
int main() {
  int K;
  scanf("%d %s", &K, s + 1);
  int N = strlen(s + 1);
  int nn = 0;
  for (int i = 1; i <= N; i++) {
    cnt[i] = cnt[i - 1] + (s[i] == '1');
    if (s[i] == '1') pos[nn++] = i;
  }
  pos[nn] = N + 1;
  long long ans = 0;
  for (int i = 1; i <= N; i++) {
    int k = cnt[i - 1];
    if (k + K > nn) break;
    ans += (pos[k + K] - max(i, pos[k + K - 1]));
  }
  cout << ans << endl;
  return 0;
}
