#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long power(long long a, long long b) {
  if (b == 0) return 1;
  long long res = power(a, b / 2);
  long long ans = res * res;
  ans %= mod;
  if (b % 2 == 0) return ans;
  return (a * ans) % mod;
}
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int k;
  cin >> k;
  string s;
  cin >> s;
  int n = s.size();
  if (!k) {
    long long res = 0, ans = 0;
    for (int i = 0; i < n + 1; i++) {
      if (i != n && s[i] == '0')
        res++;
      else {
        ans += res * (res + 1) / 2;
        res = 0;
      }
    }
    cout << ans << "\n";
    return 0;
  }
  vector<long long> dp(n);
  int cnt = 0, kpos = -1, first_one = n;
  set<int> st;
  for (int i = 0; i < n; i++) {
    if (s[i] == '1') {
      st.insert(i);
      cnt++;
      first_one = min(first_one, i);
      if (cnt == k) kpos = i;
    }
  }
  if (kpos == -1) {
    cout << 0 << "\n";
    return 0;
  }
  dp[kpos] = first_one + 1;
  int stpos = 0;
  for (int i = kpos + 1; i < n; i++) {
    dp[i] = dp[i - 1];
    if (s[i] == '1') {
      int first1 = *st.begin();
      st.erase(first1);
      dp[i] -= (first1 - stpos + 1);
      int second1 = *st.begin();
      dp[i] += second1 - first1;
      stpos = first1 + 1;
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) ans += dp[i];
  cout << ans << "\n";
  return 0;
}
