This can be solved in polynomial time O(nm2) using dynamic programming.
Let f (i, r) be the number of ways to build a sequence a'0, a'1, ..., a'i such that
(a0 + a1, ... + ai - a'0 - a'1 - ... - a'i) mod m = r.
The choice of the first parameter is obvious: we will look at the sequence from left to right and record the result for prefixes of the sequence.
The second parameter is the remainder of what we have so far modulo m, since in order to build all possible sequences, we have to consider all possible remainders in between, not just zero.
To calculate f (i, r), we will need to consider the possible choices of (ai - a'i) mod m and use the previously calculated f (i - 1, *).
If (ai - a'i) mod m = 0, there are u = [ai / m] + 1 such choices of a'i: these are ai, ai - m, a'i - 2 m, ..., a'i - u m.
So, we must add ([ai / m] + 1) * f (i - 1, r) to our answer: for each possible answer of length i - 1 with total remainder r, we can choose each of the [ai / m] + 1 possible values of a'i such that the total remainder of the new sequence is also r.
If (ai - a'i) mod m = m - 1, there are v = [(ai - 1) / m] + 1 such choices of a'i: these are ai - 1, ai - 1 - m, a'i - 1 - 2 m, ..., a'i - 1 - v m.
So, we must add ([(ai - 1) / m] + 1) * f (i - 1, (r + m - 1) mod m) to our answer: for each possible answer of length i - 1 with total remainder (r + m - 1) mod m, we can choose each of the [(ai - 1) / m] + 1 possible values of a'i such that the total remainder of the new sequence is now r.
...
If (ai - a'i) mod m = 1, there are w = [(ai - (m - 1)) / m] + 1 such choices of a'i: these are ai - (m - 1), ai - (m - 1) - m, a'i - (m - 1) - 2 m, ..., a'i - (m - 1) - w m.
So, we must add ([(ai - (m - 1)) / m] + 1) * f (i - 1, (r + 1) mod m) to our answer: for each possible answer of length i - 1 with total remainder (r + 1) mod m, we can choose each of the [(ai - (m - 1)) / m] + 1 possible values of a'i such that the total remainder of the new sequence is now r.
To sum that up,
f (i, r) = sum {by s = 0 to m - 1} of ([(ai - s) / m] + 1) * f (i - 1, (r + m - s) mod m).
We do that for all i and all r.
The base will be f (-1, 0) = 1 (there is one empty sequence with total remainder 0) and f (-1, t) = 0 for t > 0 (there are no empty sequences with total remainder > 0).
The answer will be f (n, 0) (the number of sequences a'0, a'1, ..., a'i with total remainder 0).
When implementing, take care to round integer division down and take the non-negative modulo: in languages close to CPU (like C or C++ or even Java), integer division and remainder calculation is rounded towards zero by default, so an integer result of -1 / 2 will be 0 and -1 mod 2 will be -1, when we need -1 and 1, respectively.