Two kinds of mimetic gravity model with higher derivatives of the mimetic field are analyzed in the Hamiltonian formalism. We first perform the Hamiltonian analysis for the mimetic gravity with a general higher derivative function and show the degrees of freedom (DOFs) is 3 which is consistent with the previous result of the Hamiltonian analysis at the perturbation level. We then perform the Hamiltonian analysis for the extended mimetic gravity with higher derivatives directly couples to the Ricci scalar in both Einstein frame and Jordan frame, and we show that different from our previous research at the cosmological perturbation level where only 3 propagating DOFs show up, this generalized mimetic model in general has 4 DOFs. To solve this discrepancy, we find out that the DOFs is reduced to 3 in the unitary gauge while the extra mode is eliminated by appropriate boundary conditions (homogeneous scalar field profile). What makes the system so special is that the Dirac matrix becomes singular in the special unitary gauge, generating extra secondary constraints and reducing the number of DOFs, so we give a similar but simpler example to illustrate how gauge choice affects the number of secondary constraints and the DOFs when the rank of the Dirac matrix is gauge dependent.