- محدودیت زمان: ۲ ثانیه
- محدودیت حافظه: ۵۱۲ مگابایت
A multi-digit column addition is a formula on adding two integers written like this:
\[ \begin{array}{cc} & 123 \\ \text{+} & 456 \\ & \text{------} \\ & 579 \\ \end{array} \]
A multi-digit column addition is written on the blackboard, but the sum is not necessarily correct. We can erase any number of the columns so that the addition becomes correct. For example, in the following addition, we can obtain a correct addition by erasing the second and the forth columns.
\[ \begin{array}{ccccc} & 12127 & & & 117 \\ \text{+} & 45618 & \Rightarrow & \text{+} & 468 \\ & \text{---------} & & & \text{------} \\ & 51825 & & & 585 \\ \end{array} \]
Your task is to find the minimum number of columns needed to be erased such that the remaining formula becomes a correct addition.
ورودی
There are multiple test cases in the input. Each test case starts with a line containing the single integer $n$, the number of digit columns in the addition ($1 \leq n \leq 1000$). Each of the next 3 lines contain a string of $n$ digits. The number on the third line is presenting the (not necessarily correct) sum of the numbers in the first and the second line. The input terminates with a line containing 0
which should not be processed.
خروجی
For each test case, print a single line containing the minimum number of columns needed to be erased.
مثال
ورودی نمونه ۱
3
123
456
579
5
12127
45618
51825
2
24
32
32
5
12299
12299
25598
0
خروجی نمونه ۱
0
2
2
1
ارسال پاسخ برای این سؤال