1 when p avoids the pattern 231, 0 otherwise — exactly the stack-sortable permutations.
On Permutation
Called as CombinatorialStat(x, "StackSortable"). The head's page has its examples.
CombinatorialStat(x, "StackSortable")