Given a permutation π of {1, . . . , n} and a positive integer k, we give an algorithm with running time 2O(k2 log k) nO(1) that decides whether π can be partitioned into at most k increasing or decreasing subsequences. Thus we resolve affirmatively the open question of whether the problem is fixed parameter tractable. This NP-complete problem is equivalent to deciding whether the cochromatic number, partitioning into the minimum number of cliques or independent sets, of a given permutation graph on n vertices is at most k. In fact, we give a more general result: within the mentioned running time, one can decide whether the cochromatic number of a given perfect graph on n vertices is at most k. To obtain our result we use a combination of two well-known techniques within parameterized algorithms, namely greedy localization and iterative compression. We further demonstrate the power of this combination by giving a 2O(k2 log k) n log n time algorithm for deciding whether a given set ...