Police, sheriff's departments receive grant