Demonstrating the possibility of implementing the Toffoli gate in crystals doped by rare-earth metal ions