Each particle that makes up a mechanical system, can be located by three independent variables labelling a point in space.
You can choose any particle in the rigid body to start with and move it any where you want, giving three independent variables needed to specify its location.
Choosing a second particle, you choose another set of three independent variables to specify its location, the obvious being spherical coordinates with the origin at the first particle. The first constraint is that the radius is a constant, leaving two remaining independent variables.
Choosing a third particle, you have complete freedom to rotate it by any angle about the axis through the first and second particles giving just one degree of freedom, the other two variables constrained.
For the remaining (N-3) particles, all three coordinates are constrained.
Therefore, the total number of degrees of freedom for a rigid body is 3+2+1 = 6, with 0+1+2+3(N-3) = (3N-2) constraints.