A - 暗証番号の入力 解説 /

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 233 点

問題文

高橋君は銀行のATMで暗証番号を入力しようとしています。このATMでは、暗証番号は L(左ボタン)と R(右ボタン)の2種類のボタンを使って入力します。

高橋君は正しい暗証番号を覚えているつもりでしたが、緊張のあまり何度か間違えてしまうかもしれません。ATMの画面には、入力した各桁が正しいかどうかがリアルタイムで表示されます。

高橋君はこれから N 桁の暗証番号を順番に入力していきます。正しい暗証番号と、高橋君が実際に入力したボタンの列が与えられるので、高橋君が連続して正しく入力できた最大の桁数を求めてください。

ここで「連続して正しく入力できた桁数」とは、間違えずに連続して正しいボタンを押せた回数のことを指します。

制約

  • 1 \leq N \leq 2 \times 10^5
  • S は長さ N の文字列である
  • T は長さ N の文字列である
  • S の各文字は L または R である
  • T の各文字は L または R である

入力

N
S
T
  • 1 行目には、暗証番号の桁数を表す整数 N が与えられる。
  • 2 行目には、正しい暗証番号を表す長さ N の文字列 S が与えられる。各文字は L または R である。
  • 3 行目には、高橋君が入力したボタンの列を表す長さ N の文字列 T が与えられる。各文字は L または R である。

出力

高橋君が連続して正しく入力できた最大の桁数を 1 行で出力してください。


入力例 1

5
LLRRL
LLRLL

出力例 1

3

入力例 2

4
LLLL
RRRR

出力例 2

0

入力例 3

10
LRLRLRLRLR
LRLRLLRLRR

出力例 3

5

入力例 4

20
RLRLRLRLRLRLRLRLRLRL
RLRLRLRLRLRLRLRLRLRL

出力例 4

20

入力例 5

1
L
R

出力例 5

0

Score : 233 pts

Problem Statement

Takahashi is trying to enter his PIN at a bank ATM. On this ATM, the PIN is entered using two types of buttons: L (left button) and R (right button).

Takahashi thought he remembered the correct PIN, but due to nervousness, he might have made mistakes several times. The ATM screen displays in real-time whether each entered digit is correct or not.

Takahashi will now enter an N-digit PIN one digit at a time. Given the correct PIN and the sequence of buttons that Takahashi actually pressed, find the maximum number of consecutive digits that Takahashi entered correctly.

Here, "the number of consecutive correctly entered digits" refers to the number of consecutive times he pressed the correct button without making a mistake.

Constraints

  • 1 \leq N \leq 2 \times 10^5
  • S is a string of length N
  • T is a string of length N
  • Each character of S is L or R
  • Each character of T is L or R

Input

N
S
T
  • The first line contains an integer N representing the number of digits in the PIN.
  • The second line contains a string S of length N representing the correct PIN. Each character is L or R.
  • The third line contains a string T of length N representing the sequence of buttons that Takahashi pressed. Each character is L or R.

Output

Print on a single line the maximum number of consecutive digits that Takahashi entered correctly.


Sample Input 1

5
LLRRL
LLRLL

Sample Output 1

3

Sample Input 2

4
LLLL
RRRR

Sample Output 2

0

Sample Input 3

10
LRLRLRLRLR
LRLRLLRLRR

Sample Output 3

5

Sample Input 4

20
RLRLRLRLRLRLRLRLRLRL
RLRLRLRLRLRLRLRLRLRL

Sample Output 4

20

Sample Input 5

1
L
R

Sample Output 5

0