To provide a counter circuit capable of accurately counting a high-frequency signal in which hazard or the like is easily generated. The method includes providing a semiconductor substrate. A Levenshtein distance is determined from the Levenshtein matrix.