From a set of $N$ $M$-dimensionnal non-zero vectors $$\{ \vec{V}^{(i)} \in \mathbb{Z}^M, i\in 1,2, ..., N \}$$ $$ \forall i, ~\vec{V}^{(i)} \neq \vec{0}$$
of integer components $V_j^{(i)} \in \mathbb{Z}$
How can one obtain the number of integer combinations $\{ a_i\}$ such that $$ \{ a_i \} \in \mathbb{Z}^N $$ and $$ \sum_i a_i \vec{V}^{(i)} = \vec 0$$
and the set of $a_i$ do not share a common integer divisor, except $1$ (or $-1$), i.e. if $\{ a_i, i \in 1, ..., N \}$ is a valid combination, $\{ 2 a_i, i \in 1, ..., N \}$ is not. $$ \{\frac{a_i}{d}\} \in \mathbb{Z}^N \Rightarrow d=\pm1 $$
To illustrate, in this example with $N=4$, $M=2$:
$$\vec{V}^{(1)} = (1,0); \vec{V}^{(2)} = (-1,-1); \vec{V}^{(3)} = (0,1); \vec{V}^{(4)} = (0,1)$$
one can easily guess the following solutions:
$$a_1 = a_2 = a_3 = 1 ~;~ a_4 = 0 $$ $$a_1 = a_2 = a_4 = 1 ~;~ a_3 = 0 $$ $$a_1 = a_2 = 2 ~;~ a_3 = a_4 = 1 $$
If I made no mistakes, these are the only possibilities here, so the answer would be $4$ in that case. My question is: how to find this number in the general case?
PS: what is the appropriate notation for $\{1, ..., N\}$ ?