Using Zeilberger’s factorization of two-stack-sortable permutations, we write a functional equation — of a strange sort — that defines their generating function according to five statistics: length, number of descents, number of right-to-left and left-to-right maxima, and a fifth statistic that is closely linked to the factorization. Then, we show how one can translate this functional equation into a polynomial one. We thus prove that our five-variable generating function for two-stack-sortable permutations is algebraic of degree 20.