import java.util.ArrayList; import java.util.Scanner; public class Andor { public static final int MAXNODES = 100000; public static Scanner in = new Scanner(System.in); public static class Node { char type; boolean eval; int numChildren; int numToFlip; ArrayList children; public Node(char type, int numChildren) { this.type = type; this.numChildren = numChildren; eval = false; numToFlip = 0; children = new ArrayList<>(); } public boolean addChild(Node child) { children.add(child); return (children.size() == numChildren); } public void print() // used for debugging { System.out.println(type); for(Node n : children) n.print(); } } public static void main(String[] args) { int n = in.nextInt(); char type = in.next().charAt(0); Node tree = buildTree(n, type); processTree(tree); System.out.println(tree.numToFlip); } public static Node buildTree(int levels, char type) { int nc = in.nextInt(); Node root = new Node(type, nc); ArrayList queue = new ArrayList<>(); Node node = root; for(int i=2; i<=levels; i++) { type = (char)('A' + 'O' - type); int numVals = nc; nc = 0; for(int j=0; j