The Complexity of the Compaction Problem