프로그램 명: ioi_code
제한시간: 2 초
//번역//

Racine Business Networks (RBN) has taken the Heuristic Algorithm Languages (HAL) company to court, claiming that HAL has taken source code from RBN UNIXO and contributed it to the open-source operating system HALnix. RBN and HAL both use a programming language with one statement per line, each of the form: STOREA = STOREB + STOREC where STOREA, STOREB, and STOREC are variable names. In particular, the first variable name starts in the first column and is followed by a space, an equals sign, a space, a second variable name, a space, the addition symbol, a space, and a third variable name. The same variable name might appear more than one time on a single line. Variable names consist of 1…8 uppercase ASCII letters (‘A’…‘Z’). RBN claims that HAL copied a consecutive sequence of lines directly from RBN's source code, making only minor modifications:

Given source code for programs from RBN and HAL, find the longest consecutive sequence of lines from HAL's program that could have come from a consecutive sequence of lines from RBN's program using the modifications above. Note that the sequences of lines from the two programs do not have to start at the same line number in both files.

입력

출력

The output file should contain a single line with a single integer that is the length of the longest consecutive sequence of lines that HAL might have copied from RBN and transformed.

입출력 예

입력

4 3
RA = RB + RC
RC = D + RE
RF = RF + RJ
RE = RF + RF
HD = HE + HF
HM = HN + D
HN = HA + HB

출력

2

Lines 1-2 of RBN's program are the same as lines 2-3 of HAL's program, if the following
variable name substitutions are performed on RBN's program: RA ® HM, RB ® D,
RC ® HN, D ® HA, RE ® HB. There is no matching with three or more lines.
출처:IOI 2003

[질/답] [제출 현황] [푼 후(0)]
[ 채 점 ] [홈으로]  [뒤 로]