Memory size reduction and memory accesses optimization are crucial issues for embedded systems. In the context of affine programs, these two challenges are classically tackled by array linearization, cache access optimization and memory size computation. Their formalization in the polyhedral model reduce to solving the following problem: count the number of solutions of a Presburger formula. In this paper we propose a novel algorithm that answers this question. We solve the Presburger formula whose solution is a union of parametric Z-polytopes and we propose an algorithm to count points in such a union of parametric Z-polytopes. These algorithms were implemented and we compare them to other existing methods. Categories and Subject Descriptors D.3.4 [Programming Languages]: Processors—Compilers, Optimization; G.2.1 [Discrete Mathematics]: Combinatorics—Counting problems General Terms Algorithms, Performance. Keywords Exact memory size computation, array linearization, cache access ...