#abc374b. B - Unvarnished Report

B - Unvarnished Report

Score : 200200 points

问题陈述

KEYENCE 有一种实事求是的报告文化,无论好坏。 因此,我们想检查报告的内容是否与原始文本完全相同。

你有两个由小写英文字母组成的字符串 SSTT。 如果 SSTT 相等,打印 00;否则,打印它们第一个不同字符的位置。 这里,如果第 ii 个字符只存在于 SSTT 中,就认为第 ii 个字符是不同的。

更精确地说,如果 SSTT 不相等,打印最小的整数 ii,满足以下条件之一:

  • 1iS1\leq i\leq |S|, 1iT1\leq i\leq |T|, 且 SiTiS_i\neq T_i
  • S<iT|S| < i \leq |T|
  • T<iS|T| < i \leq |S|

这里,S|S|T|T| 分别表示 SSTT 的长度,SiS_iTiT_i 分别表示 SSTT 的第 ii 个字符。

以上为大语言模型 kimi 翻译,仅供参考。

Problem Statement

KEYENCE has a culture of reporting things as they are, whether good or bad.
So we want to check whether the reported content is exactly the same as the original text.

You are given two strings SS and TT, consisting of lowercase English letters.
If SS and TT are equal, print 00; otherwise, print the position of the first character where they differ.
Here, if the ii-th character exists in only one of SS and TT, consider that the ii-th characters are different.

More precisely, if SS and TT are not equal, print the smallest integer ii satisfying one of the following conditions:

  • 1iS1\leq i\leq |S|, 1iT1\leq i\leq |T|, and SiTiS_i\neq T_i.
  • S<iT|S| < i \leq |T|.
  • T<iS|T| < i \leq |S|.

Here, S|S| and T|T| denote the lengths of SS and TT, respectively, and SiS_i and TiT_i denote the ii-th characters of SS and TT, respectively.

Constraints

  • SS and TT are strings of length between 11 and 100100, inclusive, consisting of lowercase English letters.

Input

The input is given from Standard Input in the following format:

SS

TT

Output

If SS and TT are equal, print 00; otherwise, print the position of the first character where they differ.

Sample Input 1

abcde
abedc

Sample Output 1

3

We have S=S= abcde and T=T= abedc.
SS and TT have the same first and second characters, but differ at the third character, so print 33.

Sample Input 2

abcde
abcdefg

Sample Output 2

6

We have S=S= abcde and T=T= abcdefg.
SS and TT are equal up to the fifth character, but only TT has a sixth character, so print 66.

Sample Input 3

keyence
keyence

Sample Output 3

0

SS and TT are equal, so print 00.