Counting permutations with no long monotone subsequence via generating trees and the kernel method