description: You are given a binary string (i. e. a string consisting of characters 0 and/or 1) s of length n. You can perform the following operation with the string s at most once: choose a substring (a contiguous subsequence) of s having exactly k characters 1 in it, and shuffle it (reorder the characters in the substring as you wish).
  
  Calculate the number of different strings which can be obtained from s by performing this operation at most once.
  
  Input
  
  The first line contains two integers n and k (2 ≤ n ≤ 5000; 0 ≤ k ≤ n).
  
  The second line contains the string s of length n, consisting of characters 0 and/or 1.
  
  Output
  
  Print one integer — the number of different strings which can be obtained from s by performing the described operation at most once. Since the answer can be large, output it modulo 998244353.
  
  Examples
  
  Input
  
  
  7 2
  1100110
  
  
  Output
  
  
  16
  
  
  Input
  
  
  5 0
  10010
  
  
  Output
  
  
  1
  
  
  Input
  
  
  8 1
  10001000
  
  
  Output
  
  
  10
  
  
  Input
  
  
  10 8
  0010011000
  
  
  Output
  
  
  1
  
  Note
  
  Some strings you can obtain in the first example:
  
    * to obtain 0110110, you can take the substring from the 1-st character to the 4-th character, which is 1100, and reorder its characters to get 0110; 
    * to obtain 1111000, you can take the substring from the 3-rd character to the 7-th character, which is 00110, and reorder its characters to get 11000; 
    * to obtain 1100101, you can take the substring from the 5-th character to the 7-th character, which is 110, and reorder its characters to get 101. 
  
  
  
  In the second example, k = 0 so you can only choose the substrings consisting only of 0 characters. Reordering them doesn't change the string at all, so the only string you can obtain is 10010.
solution: import java.io.*;
  import java.util.*;
  
  public class D {
      static long[] fact, inv;
      static int n, k;
      static int[] arr;
      static long MOD = (long)998244353;
      public static void main(String[] args) throws IOException{
          FastIO file = new FastIO();
          n = file.nextInt();
          k = file.nextInt();
          String s = file.next();
          int[] ones = new int[n];
          int cnt = 0;
          arr = new int[n];
          for (int i=0; i<n; i++){
              arr[i] = s.charAt(i)-'0';
              if (arr[i] == 1){
                  ones[cnt++] = i;
              }
          }
          setupCombination(n);
          if (cnt < k || k == 0){
              file.println(1);
          }else if (cnt == k){
              file.println(C(n, k));
          }else{
              long ans = 0;
              for (int i=k-1; i<cnt; i++){
                  int l = 0;
                  if (i-k >= 0){
                      l = ones[i-k]+1;
                  }
                  int r = n-1;
                  if (i+1 < cnt){
                      r = ones[i+1]-1;
                  }
                  if (r-l+1 < k){
                      System.out.println();
                  }
                  ans = add(ans, C(r-l+1, k));
                  if (i != k-1){
                      ans = subtract(ans, C(ones[i]-l, k-1));
                  }
              }
              file.println(ans);
          }
          file.close();
      }
      public static void setupCombination(int n){
          fact = new long[n+1]; // factorial
          inv = new long[n+1]; // inv[i] = multiplicative inverse of i factorial
          fact[0] = 1;
          inv[0] = 1;
          for (int i=1; i<=n; i++){
              fact[i] = multiply(fact[i-1], i);
              inv[i] = multiply(inv[i-1], binpow(i, MOD-2));
          }
      }
      public static long C(int a, int b){ // a choose b
          return multiply(fact[a], multiply(inv[b], inv[a-b]));
      }
      public static long subtract(long a, long b){
          return (((a%MOD) - (b%MOD)) + MOD)%MOD;
      }
      public static long binpow(long a, long b){ // Iterative binary exponentiation
          long res = 1;
          while (b > 0){
              if (b % 2 != 0){
                  res = multiply(a, res);
              }
              a = multiply(a, a);
              b /= 2;
          }
          return res; 
      }
      public static long multiply(long a, long b){
          return ((a%MOD) * (b%MOD))%MOD;
      }
      public static long add(long a, long b){
          return ((a%MOD) + (b%MOD))%MOD;
      }
      static class FastIO extends PrintWriter {
          private InputStream stream;
          private byte[] buf = new byte[1<<16];
          private int curChar, numChars;
      
          public FastIO() { this(System.in,System.out); }
          public FastIO(InputStream i, OutputStream o) {
              super(o);
              stream = i;
          }
          public FastIO(String i, String o) throws IOException {
              super(new FileWriter(o));
              stream = new FileInputStream(i);
          }
          public FastIO(String i) throws IOException {
              super(System.out);
              stream = new FileInputStream(i);
          }
          // throws InputMismatchException() if previously detected end of file
          private int nextByte() {
              if (numChars == -1) throw new InputMismatchException();
              if (curChar >= numChars) {
                  curChar = 0;
                  try {
                      numChars = stream.read(buf);
                  } catch (IOException e) {
                      throw new InputMismatchException();
                  }
                  if (numChars == -1) return -1; // end of file
              }
              return buf[curChar++];
          }
          // to read in entire lines, replace c <= ' '
          // with a function that checks whether c is a line break
          public String next() {
              int c; do { c = nextByte(); } while (c <= ' ');
              StringBuilder res = new StringBuilder();
              do { res.appendCodePoint(c); c = nextByte(); } while (c > ' ');
              return res.toString();
          }
          public int nextInt() {
              int c; do { c = nextByte(); } while (c <= ' ');
              int sgn = 1; if (c == '-') { sgn = -1; c = nextByte(); }
              int res = 0;
              do {
                  if (c < '0' || c > '9')
                      throw new InputMismatchException();
                  res = 10*res+c-'0';
                  c = nextByte();
              } while (c > ' ');
              return res * sgn;
          }
          public long nextLong() {
              int c; do { c = nextByte(); } while (c <= ' ');
              int sgn = 1; if (c == '-') { sgn = -1; c = nextByte(); }
              long res = 0;
              do {
                  if (c < '0' || c > '9')
                      throw new InputMismatchException();
                  res = 10*res+c-'0';
                  c = nextByte();
              } while (c > ' ');
              return res * sgn;
          }
          public double nextDouble() { return Double.parseDouble(next()); }
      }
  }