Degrees of freedom never characterize velocities in a system. They characterize set of possible positions of the system. Formal definition is as follows. Let a system consists of ##N## mass points with radius-vectors ##\boldsymbol r_1,\ldots,\boldsymbol r_N##. Assume that this system is subordinated to the following constraints
$$\sum_{i=1}^N\Big(\boldsymbol a_{ij}(t,\boldsymbol r_1,\ldots,\boldsymbol r_N),\boldsymbol{\dot r}_i\Big)+b_j(t,\boldsymbol r_1,\ldots,\boldsymbol r_N)=0,\quad j=1,\ldots, n<3N.$$
The vectors ##\xi_j=(\boldsymbol a_{1j},\ldots, \boldsymbol a_{Nj})\in \mathbb{R}^{3N}## are linearly independent.
If the constraints are holonomic: ##f_j(t,\boldsymbol r_1,\ldots,\boldsymbol r_N)=0## then this case is reduced to the previous one by differentiation in ##t##:
$$\sum_{i=1}^N\Big(\frac{\partial f_j}{\partial \boldsymbol r_i},\boldsymbol{\dot r}_i\Big)+\frac{\partial f_j}{\partial t}=0.$$
By definition, the vector space of virtual displacements consists of vectors ##(\delta \boldsymbol r_1,\ldots,\delta\boldsymbol r_N)\in\mathbb{R}^{3N}## such that
$$\sum_{i=1}^N\Big(\boldsymbol a_{ij},\delta\boldsymbol r_i\Big)=0.$$
By definition the number of degrees of freedom equals dimension of the space of virtual displacements. It is easy to see that the number of degrees of freedom is equal to ##3N-n##