We prove the first time-space tradeoffs for counting the number of solutions to an NP problem modulo small integers, and also improve upon known time-space tradeoffs for Sat. Let m > 0 be an integer, and define MOD m -Sat to be the problem of determining if a given Boolean formula has exactly km satisfying assignments, for some integer k. We show for all primes p except for possibly one of them, and for all c < 2 cos(π/7) ≈ 1.801, there is a d > 0 such that MOD p -Sat is not solvable in n c time and n d space by general algorithms. That is, there is at most one prime p that does not satisfy the tradeoff. We prove that the same limitation holds for Sat and MOD 6 -Sat, as well as MOD m -Sat for any composite m that is not a prime power. Our main tool is a general method for rapidly simulating deterministic computations with restricted space, by counting the number of solutions to NP predicates modulo integers. The simulation converts an ordinary algorithm into a "canonical" one that consumes roughly the same amount of time and space, yet canonical algorithms have nice properties suitable for counting.