#include <bits/stdc++.h>
using namespace std;
string str;
long long int dp[1000005];
int main() {
  long long int k, i;
  cin >> k;
  cin >> str;
  long long int num = 0;
  long long int total = 0;
  for (i = str.length() - 1; i >= 0; i--) {
    if (str[i] == '1') {
      num++;
      total++;
    } else {
      dp[num]++;
    }
  }
  num = 0;
  long long int ans = 0;
  if (k == 0) {
    for (i = 0; i < str.length(); i++) {
      if (str[i] == '1') {
        ans = ans + (num * (num + 1)) / 2;
        num = 0;
      } else {
        num++;
      }
    }
    ans = ans + (num * (num + 1)) / 2;
    cout << ans << endl;
    return 0;
  }
  num = 0;
  ans = 0;
  for (i = 0; i < str.length(); i++) {
    if (total - num < k) break;
    ans = ans + (dp[total - num - k] + 1);
    if (str[i] == '1') num++;
  }
  cout << ans << endl;
}
