Data structure BF and KMP algorithm