Pattern recognition apparatus for detecting a specified pattern in an input signal