sub i{sort{$a-$b}glob<>}@b=i;i;@d=1;map{$d[$_+!($'<$b[$_]|$_>2)]+=$d[$_]for 3,2,//,0}i;print$d[3]