#include <bits/stdc++.h>
using namespace std;
long k;
string s;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> k;
  cin >> s;
  s += '1';
  long dem = 0;
  long l = -1;
  long long ans = 0;
  for (long i = 0; i < s.size(); i++) {
    if (s[i] == '1') dem++;
    if (dem > k) {
      if (k == 0) {
        ans += 1ll * (i - l) * (i - l - 1) / 2;
        l = i;
      } else {
        long tmp1 = 0;
        long tmp2 = 0;
        for (l += 1; l < i; l++) {
          if (s[l] == '1') break;
          tmp1++;
        }
        for (long j = i - 1; j > l; j--) {
          if (s[j] == '1') break;
          tmp2++;
        }
        ans += tmp1 + tmp2 + 1ll * tmp1 * tmp2 + 1;
      }
      dem--;
    }
  }
  cout << ans;
  return 0;
}
