import java.io.*; import java.util.*; class Main { public static void main(String args[])throws Exception { BufferedReader bu=new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb=new StringBuilder(); String s=bu.readLine(); int n=s.length(); Stack st=new Stack<>(); Stack val=new Stack<>(); //0-( 1-max 2-mex 3-m?x 4-0,1,2,? int i; long M=998244353; for(i=0;i