You are given two strings $s$ and $t$. In a single move, you can choose any of two strings and delete the first (that is, the leftmost) character. After a move, the length of the string decreases by $1$. You can't choose a string if it is empty.

For example:  by applying a move to the string "where", the result is the string "here",  by applying a move to the string "a", the result is an empty string "". 

You are required to make two given strings equal using the fewest number of moves. It is possible that, in the end, both strings will be equal to the empty string, and so, are equal to each other. In this case, the answer is obviously the sum of the lengths of the initial strings.

Write a program that finds the minimum number of moves to make two given strings $s$ and $t$ equal.


-----Input-----

The first line of the input contains $s$. In the second line of the input contains $t$. Both strings consist only of lowercase Latin letters. The number of letters in each string is between 1 and $2\cdot10^5$, inclusive.


-----Output-----

Output the fewest number of moves required. It is possible that, in the end, both strings will be equal to the empty string, and so, are equal to each other. In this case, the answer is obviously the sum of the lengths of the given strings.


-----Examples-----
Input
test
west

Output
2

Input
codeforces
yes

Output
9

Input
test
yes

Output
7

Input
b
ab

Output
1



-----Note-----

In the first example, you should apply the move once to the first string and apply the move once to the second string. As a result, both strings will be equal to "est".

In the second example, the move should be applied to the string "codeforces" $8$ times. As a result, the string becomes "codeforces" $\to$ "es". The move should be applied to the string "yes" once. The result is the same string "yes" $\to$ "es".

In the third example, you can make the strings equal only by completely deleting them. That is, in the end, both strings will be empty.

In the fourth example, the first character of the second string should be deleted.

Difficulty: EASY
Tags: String algorithms

Implementation

Complete search
Skill types: Complete search

Starter code:

Solutions:
s = str(input())
t = str(input())
(x, y) = (0, min(len(s), len(t)))
z = max(len(s), len(t))
i = 0
while i < y:
	if s[-1 - i] != t[-1 - i]:
		break
	else:
		i += 1
x = 2 * (y - i) + (z - y)
print(x)


(s, t) = (input(), input())
(i, j) = (len(s), len(t))
while i and j and (s[i - 1] == t[j - 1]):
	i -= 1
	j -= 1
print(i + j)


s = input()
t = input()
point = len(s) + len(t)
(minus, i, j) = (0, len(s) - 1, len(t) - 1)
while i >= 0 and j >= 0:
	if s[i] == t[j]:
		minus += 2
	else:
		break
	i -= 1
	j -= 1
print(point - minus)


def main():
	(s, t) = (input(), input())
	s = s[::-1]
	t = t[::-1]
	length_s = len(s)
	length_t = len(t)
	try:
		index = next((i for i in range(min(length_s, length_t)) if s[i] != t[i]))
		print(length_t - index + length_s - index)
	except StopIteration:
		print(abs(length_s - length_t))
main()


s1 = input()
s2 = input()
ans = 0
l1 = len(s1)
l2 = len(s2)
if l1 > l2:
	ans += l1 - l2
	s1 = s1[l1 - l2:]
elif l2 > l1:
	ans += l2 - l1
	s2 = s2[l2 - l1:]
s1 = s1[::-1]
s2 = s2[::-1]
n = len(s1)
i = 0
while i < n and s1[i] == s2[i]:
	i += 1
ans += 2 * (len(s1) - i)
print(ans)


s = input()
t = input()
i = len(s) - 1
j = len(t) - 1
ans = 0
while i >= 0 and j >= 0:
	if s[i] == t[j]:
		ans = ans + 2
	else:
		break
	i = i - 1
	j = j - 1
print(len(s) + len(t) - ans)


A = input()
B = input()
A = A[::-1]
B = B[::-1]
lena = len(A)
lenb = len(B)
i = 0
ans = 0
while True:
	if lena != 0 and lenb != 0 and (A[i] == B[i]):
		lena -= 1
		lenb -= 1
		i += 1
	else:
		break
ans = lena + lenb
print(ans)


s = str(input())
s1 = str(input())
if len(s) == len(s1):
	c = 0
	flag = 0
	for i in range(0, len(s)):
		if s[i] != s1[i]:
			c = i
			flag = 1
	if flag > 0:
		print((c + 1) * 2)
	else:
		print(0)
elif len(s) > len(s1):
	d = len(s) - len(s1)
	s = s[d:]
	c = 0
	flag = 0
	for i in range(0, len(s)):
		if s[i] != s1[i]:
			flag = 1
			c = i
	if flag > 0:
		print(d + (c + 1) * 2)
	else:
		print(d)
else:
	d = len(s1) - len(s)
	s1 = s1[d:]
	c = 0
	flag = 0
	for i in range(0, len(s1)):
		if s1[i] != s[i]:
			flag = 1
			c = i
	if flag > 0:
		print(d + (c + 1) * 2)
	else:
		print(d)


x = input()
y = input()
if len(x) == len(y):
	k = 0
	for val in range(len(x) - 1, -1, -1):
		if x[val] == y[val]:
			k += 1
		else:
			break
	print((len(x) - k) * 2)
elif len(x) > len(y):
	f = ''
	kl = len(x) - len(y)
	for g in range(kl, len(x)):
		f += x[g]
	k = 0
	for val in range(len(y) - 1, -1, -1):
		if f[val] == y[val]:
			k += 1
		else:
			break
	print(kl + (len(y) - k) * 2)
else:
	f = ''
	kl = len(y) - len(x)
	for g in range(kl, len(y)):
		f += y[g]
	k = 0
	for val in range(len(x) - 1, -1, -1):
		if f[val] == x[val]:
			k += 1
		else:
			break
	print(kl + (len(x) - k) * 2)


s1 = input()[::-1]
s2 = input()[::-1]
k = 0
while k < min(len(s1), len(s2)) and s1[k] == s2[k]:
	k += 1
a = len(s1) + len(s2) - 2 * k
print(a)


s = input()
t = input()
m = min(len(s), len(t))
sum_ = len(s) + len(t)
ans = sum_
i = -1
while s[i] == t[i]:
	ans -= 2
	if i == -m:
		break
	i -= 1
print(ans)


(s, t) = (input(), input())
(sl, tl) = (len(s), len(t))
while sl and tl and (s[sl - 1] == t[tl - 1]):
	sl -= 1
	tl -= 1
print(sl + tl)


op = list(input())
po = list(input())
count = 0
if op[-1] != po[-1]:
	print(len(op) + len(po))
elif ''.join(po) == ''.join(op):
	print('0')
elif len(op) > len(po):
	x = -1
	for g in range(len(po)):
		if po[x] == op[x]:
			x -= 1
		else:
			x += 1
			tan = len(op) + x
			kan = len(po) + x
			count = 1
			print(tan + kan)
			break
	if count != 1:
		print(len(op) - len(po))
	else:
		pass
elif len(op) < len(po):
	x = -1
	for g in range(len(op)):
		if po[x] == op[x]:
			x -= 1
		else:
			x += 1
			tan = len(op) + x
			kan = len(po) + x
			count = 1
			print(tan + kan)
			break
	if count != 1:
		print(len(po) - len(op))
	else:
		pass
else:
	x = -1
	for g in range(len(po)):
		if po[x] == op[x]:
			x -= 1
		else:
			x += 1
			tan = len(op) + x
			kan = len(po) + x
			count = 1
			print(tan + kan)
			break


a = input()
b = input()
c = len(a)
d = len(b)
while c and d and (a[c - 1] == b[d - 1]):
	c = c - 1
	d = d - 1
print(c + d)


a = input()
b = input()
a = a[::-1]
b = b[::-1]
n = min(len(a), len(b))
ans = len(a) + len(b)
a = a[:n]
b = b[:n]
for (x, y) in zip(a, b):
	if x != y:
		break
	ans -= 2
print(ans)


s = input()
t = input()
ds = len(s)
dt = len(t)
while s[ds - 1] == t[dt - 1] and ds > 0 and (dt > 0):
	ds -= 1
	dt -= 1
print(ds + dt)


z = input
mod = 10 ** 9 + 7
from string import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0:
			return 0
	return 1
l1 = z()
l2 = z()
(i, j) = (len(l1) - 1, len(l2) - 1)
while i >= 0 and j >= 0 and (l1[i] == l2[j]):
	i -= 1
	j -= 1
print(i + j + 2)


s = input()
t = input()
count = 0
while True:
	i = len(s) - count - 1
	j = len(t) - count - 1
	if i >= 0 and j >= 0 and (s[i] == t[j]):
		count += 1
	else:
		break
print(len(s) + len(t) - 2 * count)


import sys
from itertools import accumulate

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
S = input()
T = input()
S = S[::-1]
T = T[::-1]
N = min(len(S), len(T))
ans = len(S) + len(T)
for i in range(N):
	if S[i] == T[i]:
		ans -= 2
	else:
		break
print(ans)


a = input()
b = input()
a = [i for i in a]
b = [i for i in b]
w = 0
while True:
	i = len(a) - w - 1
	j = len(b) - w - 1
	if i >= 0 and j >= 0 and (a[i] == b[j]):
		w += 1
	else:
		break
print(len(a) + len(b) - 2 * w)


s1 = input()
s2 = input()
s1 = list(s1)
s2 = list(s2)
n = min(len(s1), len(s2))
z = 0
count = 0
for i in range(n):
	if s1[len(s1) - 1 - i] == s2[len(s2) - 1 - i]:
		count += 1
	else:
		break
if z == 0:
	print(len(s1) + len(s2) - 2 * count)


word = input()
lord = input()
o = -1
while -o <= len(word) and -o <= len(lord) and (word[o] == lord[o]):
	o = o - 1
print(len(word) + len(lord) + 2 + 2 * o)


def getcount(s1, s2, l1, l2):
	j = l2 - 1
	i = l1 - 1
	count = 0
	while s2[j] == s1[i] and j >= 0:
		count += 1
		j -= 1
		i -= 1
	return count
s1 = input()
s2 = input()
l1 = len(s1)
l2 = len(s2)
if l1 > l2:
	count = getcount(s1, s2, l1, l2)
else:
	count = getcount(s2, s1, l2, l1)
print(l1 + l2 - 2 * count)


(a, b) = (input(), input())
m = a[::-1]
n = b[::-1]
l = len(m) + len(n)
for i in range(min(len(a), len(b))):
	if m[i] == n[i]:
		l -= 2
	else:
		break
print(l)


s = input()
t = input()
s2 = s[::-1]
t2 = t[::-1]
ans = len(s) + len(t)
n = min(len(s), len(t))
for i in range(n):
	if s2[i] == t2[i]:
		ans -= 2
	else:
		break
print(ans)


l = input()
m = input()
count = 0
j = 1
for i in range(len(m) - 1, -1, -1):
	if j <= len(l) and m[i] == l[-j]:
		count += 2
		j += 1
	else:
		break
print(len(l) + len(m) - count)


s1 = input()
s2 = input()
s1 = s1[::-1]
s2 = s2[::-1]
i = 0
while i < min(len(s1), len(s2)):
	if s1[i] != s2[i]:
		print(len(s1) + len(s2) - 2 * i)
		break
	elif i == min(len(s1), len(s2)) - 1:
		print(max(len(s1), len(s2)) - min(len(s1), len(s2)))
		break
	else:
		i = i + 1


(x, y, n) = (list(map(str, input()))[::-1], list(map(str, input()))[::-1], 0)
for i in range(min(len(x), len(y))):
	if x[i] != y[i]:
		n = len(x) - i + (len(y) - i)
		break
print(n if n != 0 else abs(len(x) - len(y)))


a = input()
b = input()
c = 0
i = len(a) - 1
j = len(b) - 1
while i >= 0 and j >= 0:
	if a[i] == b[j]:
		c += 1
	else:
		break
	i -= 1
	j -= 1
m1 = len(a) - c
m2 = len(b) - c
print(m1 + m2)


from __future__ import division, print_function
from sys import stdin, stdout
import bisect
from bisect import bisect_left as bl
from bisect import bisect_right as br
import itertools
from collections import Counter
import collections
import math
import heapq
import re

def modinv(n, p):
	return pow(n, p - 2, p)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def most_frequent(list):
	return max(set(list), key=list.count)

def GCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def ncr(n, r, p):
	t = fact[n] * (ifact[r] * ifact[n - r] % p) % p
	return t

def Convert(string):
	li = list(string.split(''))
	return li

def SieveOfEratosthenes(n):
	global prime
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	f = []
	for p in range(2, n):
		if prime[p]:
			f.append(p)
	return f
prime = []
q = []

def dfs(n, d, v, c):
	global q
	v[n] = 1
	x = d[n]
	q.append(n)
	j = c
	for i in x:
		if i not in v:
			f = dfs(i, d, v, c + 1)
			j = max(j, f)
	return j

def main():
	a = list(sin())
	b = list(sin())
	x = len(a)
	y = len(b)
	count = 0
	while (x > 0 and y > 0) and a[x - 1] == b[y - 1]:
		x = x - 1
		y = y - 1
	print(x + y)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


s = input()
t = input()
a = len(s)
b = len(t)
while a >= 1 and b >= 1 and (s[a - 1] == t[b - 1]):
	a -= 1
	b -= 1
print(a + b)


s = list(input())
t = list(input())
(a, b) = (len(s), len(t))
m = min([a, b])
c = 0
for i in range(m):
	if s[a - 1 - i] == t[b - 1 - i]:
		c += 2
	else:
		break
print(a + b - c)


s1 = input()
s2 = input()
ls1 = len(s1)
ls2 = len(s2)
c = 0
if ls1 == ls2:
	l = ls1
	for i in range(l):
		if s1[-1 - i] == s2[-1 - i]:
			c += 1
		else:
			break
elif ls1 > ls2:
	l = ls2
	for i in range(l):
		if s1[-1 - i] == s2[-1 - i]:
			c += 1
		else:
			break
else:
	l = ls1
	for i in range(l):
		if s1[-1 - i] == s2[-1 - i]:
			c += 1
		else:
			break
print(ls1 + ls2 - 2 * c)


(listOne, listTwo) = (list(input()), list(input()))
while min(len(listOne), len(listTwo)) > 0 and listOne[-1] == listTwo[-1]:
	listOne.pop()
	listTwo.pop()
solution = len(listOne) + len(listTwo)
print(solution)


def solve(str1, str2):
	if str1 == str2:
		return 0
	if len(str1) == 0 or len(str2) == 0:
		return max(len(str1), len(str2))
	(i, j) = (len(str1) - 1, len(str2) - 1)
	Count = 0
	while i >= 0 and j >= 0 and (str1[i] == str2[j]):
		i -= 1
		j -= 1
		Count += 1
	return len(str1) + len(str2) - 2 * Count
str1 = str(input())
str2 = str(input())
print(solve(str1, str2))


s = input()
t = input()
if s[-1] != t[-1]:
	print(len(s) + len(t))
else:
	j = -1
	while -j - 1 < min(len(s), len(t)) and s[j] == t[j]:
		j -= 1
	j += 1
	print(len(s) + len(t) + 2 * j)


a = input()
b = input()
i = -1
while i >= -min(len(a), len(b)) and a[i] == b[i]:
	i -= 1
print(len(a) + len(b) + 2 * i + 2)


s1 = input()
s2 = input()
ans = 0
cursor = -1
while -cursor <= min(len(s1), len(s2)) and s1[cursor] == s2[cursor]:
	cursor -= 1
	ans += 1
print(len(s1) + len(s2) - ans * 2)


a = input()
b = input()
n = min(len(a), len(b))
x = 0
(aa, bb) = (len(a), len(b))
a = list(a)
b = list(b)
for i in range(min(len(a), len(b))):
	if a[-1] == b[-1]:
		x += 1
	else:
		break
	a.pop()
	b.pop()
ans = aa - x + bb - x
print(ans)


s1 = input()
s2 = input()
n = len(s1)
m = len(s2)
maxi = max(n, m)
s1 = '*' * (maxi - n) + s1
s2 = '&' * (maxi - m) + s2
c = 0
for i in range(maxi - 1, maxi - min(n, m) - 1, -1):
	if s1[i] == s2[i]:
		c += 1
	else:
		break
print(n + m - 2 * c)


import sys
import os

def test(str1, str2, n):
	return str2.endswith(str1[len(str1) - n:])

def deleteFromLeft(str1, str2):
	n = min(len(str1), len(str2))
	if test(str1, str2, n):
		return abs(len(str1) - len(str2))
	left = 0
	right = n
	while right > left + 1:
		mid = (left + right) // 2
		if test(str1, str2, mid):
			left = mid
		else:
			right = mid
	return len(str1) + len(str2) - 2 * left

def main():
	str1 = input()
	str2 = input()
	print(deleteFromLeft(str1, str2))
main()


a = input()
b = input()
i = len(a)
j = len(b)
k = i + j
while a[i - 1] == b[j - 1] and i > 0 and (j > 0):
	i = i - 1
	j = j - 1
	k = k - 2
print(k)


s1 = input()
s2 = input()
l1 = len(s1)
l2 = len(s2)
ans = 0
if l1 > l2:
	l = l2
	ans += l1 - l2
	l1 = l1 - l2
	l2 = 0
elif l2 > l1:
	l = l1
	ans += l2 - l1
	l2 = l2 - l1
	l1 = 0
else:
	l = l1
	l1 = 0
	l2 = 0
res = 2
for i in range(l):
	if s1[i + l1] == s2[i + l2]:
		res += 2
	else:
		ans += res
		res = 2
print(ans)


s1 = input()
s2 = input()
l1 = len(s1)
l2 = len(s2)
ans = 0
for i in range(1, max(l1, l2) + 1):
	if i <= l1 and i <= l2 and (s1[-i] == s2[-i]):
		ans += 1
	else:
		break
print(int(l1 + l2 - ans * 2))


s = input()
t = input()
ls = len(s)
lt = len(t)
longestcommon = 0
minlen = min(ls, lt)
i = ls - 1
j = lt - 1
while minlen > 0:
	if s[i] == t[j]:
		longestcommon += 1
		i -= 1
		j -= 1
	else:
		break
	minlen -= 1
res = ls - longestcommon + (lt - longestcommon)
print(res)


s = input()
t = input()
s = s[::-1]
t = t[::-1]
cnt = 0
if len(s) < len(t):
	l = len(s)
else:
	l = len(t)
for i in range(l):
	if s[i] == t[i]:
		cnt += 2
	else:
		break
print(len(s) + len(t) - cnt)


s = str(input())
t = str(input())
s = s[::-1]
t = t[::-1]
ns = len(s)
nt = len(t)
i = 0
res = ns + nt
if min(ns, nt) == 1:
	if s[0] == t[0]:
		res = max(ns, nt) - 1
else:
	while t[i] == s[i]:
		res -= 2
		i = i + 1
		if i == min(ns, nt):
			break
print(res)


s = input()
t = input()
if len(s) < len(t):
	(s, t) = (t, s)
sunm = 0
c = 0
for j in range(-1, -len(t) - 1, -1):
	if s[j] == t[j]:
		c += 1
		continue
	else:
		break
sunm = len(s) + len(t) - 2 * c
print(sunm)


a = input()
b = input()
m = 0
if len(a) > len(b):
	m = len(b)
else:
	m = len(a)
j = 0
for i in range(m):
	if a[len(a) - i - 1] != b[len(b) - i - 1]:
		break
	else:
		j += 1
print(len(a) + len(b) - 2 * j)


s = list(input())
t = list(input())
s = s[::-1]
t = t[::-1]
a = len(s)
b = len(t)
count = 0
if a >= b:
	for i in range(b):
		if s[i] == t[i]:
			count += 1
		else:
			break
else:
	for i in range(a):
		if s[i] == t[i]:
			count += 1
		else:
			break
print(a + b - 2 * count)


def main():
	s = input()
	t = input()
	for i in range(-1, -min(len(s), len(t)) - 1, -1):
		if s[i] != t[i]:
			i += 1
			break
	print(len(s) + len(t) + 2 * i)
main()


def solve(s1, s2):
	count = 0
	for i in range(min(len(s1), len(s2))):
		if s1[~i] != s2[~i]:
			break
		count += 2
	return len(s1) + len(s2) - count
s1 = input().strip()
s2 = input().strip()
result = solve(s1, s2)
print(result)


s = input()
t = input()
l1 = len(s)
l2 = len(t)
c = 0
a = l1
b = l2
while l1 >= 1 and l2 >= 1 and (s[l1 - 1] == t[l2 - 1]):
	l1 -= 1
	l2 -= 1
print(l1 + l2)


s1 = input()
s2 = input()
count = 0
if s1 != '' and s2 != '':
	len1 = len(s1)
	len2 = len(s2)
	length = len1 if len1 < len2 else len2
	for i in range(length):
		if s1[len1 - 1] == s2[len2 - 1]:
			count += 1
			len1 -= 1
			len2 -= 1
			length -= 1
		else:
			break
	result = len(s1) + len(s2) - count * 2
	print(result)


a = input().strip()
b = input().strip()
common = 0
while True:
	if common >= min(len(a), len(b)):
		break
	if a[-(common + 1)] != b[-(common + 1)]:
		break
	common += 1
print(len(a) - common + len(b) - common)


a = input()
b = input()
(a_len, b_len) = (len(a), len(b))
len_Sum = a_len + b_len
counter = 0
for ind in range(-1, min(a_len, b_len) * -1 - 1, -1):
	if a[ind] != b[ind]:
		break
	else:
		counter += 2
print(len_Sum - counter)


s1 = str(input())
s2 = str(input())
if s1 == s2:
	print(0)
else:
	r1 = len(s1) - 1
	r2 = len(s2) - 1
	n = r1 + r2 + 2
	while r1 >= 0 and r2 >= 0:
		if s1[r1] != s2[r2]:
			break
		r1 -= 1
		r2 -= 1
		n -= 2
	print(n)


s = input()
t = input()
if s == t:
	print('0')
elif len(s) == 1 and len(t) == 1 and (s != t):
	print('2')
else:
	i = 0
	j = 0
	n = 0
	if len(s) > len(t):
		i = len(t) - 1
		j = len(s) - 1
		flag = 1
		while i >= 0:
			if t[i] == s[j]:
				n += 1
			else:
				break
			i = i - 1
			j = j - 1
		n = n * 2
		if flag != -1:
			print(len(s) + len(t) - n)
	else:
		i = len(s) - 1
		j = len(t) - 1
		while i >= 0:
			if s[i] == t[j]:
				i = i - 1
				j = j - 1
				n += 1
			else:
				break
		n = n * 2
		print(len(s) + len(t) - n)


s = input()
t = input()
if s == '' or t == '':
	print(len(s) + len(t))
elif s[-1] != t[-1]:
	print(len(s) + len(t))
elif s == t:
	print(0)
else:
	tims = 0
	if len(s) > len(t):
		while len(s) > len(t):
			s = s[1:]
			tims += 1
	elif len(t) > len(s):
		while len(t) > len(s):
			t = t[1:]
			tims += 1
	for v in range(len(s) - 1, -1, -1):
		if s == v:
			break
		if s[v] == t[v]:
			pass
		else:
			tims += (v + 1) * 2
			break
	print(tims)


def scanf(obj=list, type=int):
	return obj(list(map(type, input().split())))
s1 = input()
s2 = input()
for i in range(1, min(len(s1), len(s2)) + 1):
	if i == min(len(s1), len(s2)) and s1[-i] == s2[-i]:
		i += 1
		break
	if s1[-i] != s2[-i]:
		break
print(len(s1) + len(s2) - 2 * i + 2)


a = ' ' + input()
b = ' ' + input()
(x, y) = (len(a) - 1, len(b) - 1)
while x and y and (a[x] == b[y]):
	x -= 1
	y -= 1
print(x + y)


first = input()
second = input()
same = 0
i = 0
first = first[::-1]
second = second[::-1]
while i < min(len(first), len(second)) and first[i] == second[i]:
	same += 1
	i += 1
print(len(first) + len(second) - same * 2)


current_line = []

def raw_input():
	global current_line
	if len(current_line) == 0:
		current_line = input().split(' ')
	return current_line.pop(0)

def getInt():
	return int(raw_input())

def readArray(k):
	return [getInt() for i in range(0, k)]
r = list(input())
q = list(input())
offset = 0
while r[len(r) - 1 - offset] == q[len(q) - 1 - offset]:
	if offset == len(r) - 1 or offset == len(q) - 1:
		print(max(len(r) - offset - 1, len(q) - offset - 1))
		exit()
	else:
		offset += 1
print(len(r) - offset + len(q) - offset)


s1 = input()
s2 = input()
c = len(s1) + len(s2)
n = len(s1) if len(s1) < len(s2) else len(s2)
k = 0
for i in range(-1, -(n + 1), -1):
	if s1[i] != s2[i]:
		break
	else:
		k += 2
print(c - k)


s = input()
t = input()
sl = len(s)
st = len(t)
n = 0
if sl > st:
	n = st
else:
	n = sl
i = 0
f = 0
ans = 0
while i < n:
	if t[-1 - i] != s[-1 - i]:
		ans = st - i + sl - i
		f = 1
		break
	i += 1
if f == 1:
	print(ans)
else:
	print(max(st, sl) - i)


def reverse(string):
	string = ''.join(reversed(string))
	return string
str1 = input()
str2 = input()
str1 = reverse(str1)
str2 = reverse(str2)
l = min(len(str1), len(str2))
c = 0
for i in range(0, l):
	if str1[i] == str2[i]:
		c += 1
	else:
		break
print(len(str1) - c + (len(str2) - c))


s = input()
t = input()
i = len(s) - 1
j = len(t) - 1
while i >= 0 and j >= 0 and (s[i] == t[j]):
	i = i - 1
	j = j - 1
print(j + i + 2)


s1 = input()
s2 = input()
c = 0
l = max(len(s1), len(s2)) - 1
l2 = min(len(s1), len(s2))
for i in range(l2 - 1, -1, -1):
	if len(s1) > len(s2):
		if s1[l] != s2[i]:
			break
		c += 1
		l -= 1
	else:
		if s2[l] != s1[i]:
			break
		c += 1
		l -= 1
ans = len(s1) + len(s2) - 2 * c
print(ans)


s = [i for i in input()]
t = [i for i in input()]
n = len(s)
m = len(t)
s.reverse()
t.reverse()
if m > n:
	(n, m) = (m, n)
	(s, t) = (t, s)
x = 0
while x < m:
	if s[x] != t[x]:
		break
	x += 1
print(m + n - 2 * x)


a = input()
b = input()
c = []
d = []
for i in a:
	c.append(i)
for i in b:
	d.append(i)
temp = True
count = 0
l1 = len(c)
k = l1
l2 = len(d)
h = l2
if l1 > l2:
	m = l2
else:
	m = l1
for i in range(1, m + 1):
	if l1 != 0 and l2 != 0:
		if c[-i] == d[-i]:
			count += 2
		else:
			break
print(k + h - count)


s = input()
t = input()
a = 0
b = 0
c = 0
d = 0
while a == 0 and b == 0:
	if s[len(s) - c - 1] != t[len(t) - c - 1]:
		a = 1
	else:
		d += 1
	c += 1
	if c == len(t):
		b = 1
	elif c == len(s):
		b = 1
print(len(s) - d + (len(t) - d))


s1 = input()
s2 = input()
c = 0
s1 = s1[::-1]
s2 = s2[::-1]
for i in range(min(len(s1), len(s2))):
	if s1[i] == s2[i]:
		c += 1
	else:
		break
print(len(s1) + len(s2) - 2 * c)


s1 = input()
s2 = input()
s1 = s1[::-1]
s2 = s2[::-1]
flag = 0
if len(s1) == len(s2) and s1 == s2:
	print('0')
else:
	n = min(len(s1), len(s2))
	for i in range(n):
		if s1[i] != s2[i]:
			flag = 1
			break
	count = 0
	if flag == 0:
		i = i + 1
		if len(s1) > i:
			count = count + len(s1) - i
		elif len(s2) > i:
			count = count + len(s2) - i
	else:
		count = count + (len(s1) - i) + (len(s2) - i)
	print(count)


a = input()
b = input()
a = a[::-1]
b = b[::-1]
end = min(len(a), len(b))
res = 0
for i in range(end):
	if a[i] == b[i]:
		res += 1
	else:
		break
print(len(a) + len(b) - res * 2)


def deleft(s, t):
	if s[-1] != t[-1]:
		return len(s) + len(t)
	if len(s) < len(t):
		b = s
		a = t
	else:
		b = t
		a = s
	lena = len(a)
	lenb = len(b)
	for i in range(1, lenb + 1):
		if b[-i] != a[-i]:
			return lena - (i - 1) + lenb - (i - 1)
	return lena - i + lenb - i
s = input()
t = input()
print(deleft(s, t))


def main():
	s1 = ''.join(reversed(input()))
	s2 = ''.join(reversed(input()))
	n = max(len(s1), len(s2))
	cnt = len(s1) + len(s2)
	for i in range(n):
		if i >= len(s1) or i >= len(s2) or s1[i] != s2[i]:
			break
		if s1[i] == s1[i]:
			cnt -= 2
	print(cnt)
main()


a = input()
b = input()
l = 0
if len(a) < len(b):
	l = len(a)
else:
	l = len(b)
res = -1
for i in range(l):
	if a[-i - 1] != b[-i - 1]:
		res = i
		break
if res == -1:
	res = l
print(len(a) + len(b) - 2 * res)


s = str(input())
t = str(input())
num = 0
for i in range(len(s)):
	if s[len(s) - i - 1] == t[len(t) - i - 1] and len(t) - i - 1 >= 0:
		num += 1
	else:
		break
print(len(s) + len(t) - 2 * num)


s = input()
t = input()
LEN_S = len(s)
LEN_T = len(t)
len_s = LEN_S
len_t = LEN_T
while s[len_s - 1] == t[len_t - 1]:
	len_s -= 1
	len_t -= 1
	if len_s == 0 or len_t == 0:
		break
print(len_s + len_t)


s = input()
t = input()
c = 0
for i in range(-1, -min(len(s), len(t)) - 1, -1):
	if s[i] != t[i]:
		break
	else:
		c = -i
print(len(s) + len(t) - 2 * c)


s = input()
t = input()
S = list(s)
T = list(t)
lens = len(s)
lent = len(t)
ma = max(lens, lent)
count = 0
for i in range(0, ma):
	try:
		if S[len(S) - 1] == T[len(T) - 1]:
			count += 1
			del S[len(S) - 1]
			del T[len(T) - 1]
		else:
			break
	except:
		break
print(len(S) + len(T))


s = input()
t = input()
count = 0

def leftSame(s, t):
	count = 0
	s_index = len(s) - 1
	t_index = len(t) - 1
	while s_index >= 0 and t_index >= 0:
		if s[s_index] == t[t_index]:
			count += 1
			s_index -= 1
			t_index -= 1
		else:
			return count
	return count
print(len(s) + len(t) - leftSame(s, t) * 2)


s1 = list(input())
s2 = list(input())
lenS1 = len(s1)
lenS2 = len(s2)
n = max(lenS1, lenS2)
maxS = s1 if lenS1 >= lenS2 else s2
minS = s2 if lenS2 <= lenS1 else s1
i = n - 1
j = len(minS) - 1
k = 0
while i >= 0 and j >= 0:
	if maxS[i] != minS[j]:
		break
	k += 1
	i -= 1
	j -= 1
if k == 0:
	print(lenS1 + lenS2)
else:
	print(lenS1 + lenS2 - 2 * k)


s1 = input().strip()
s2 = input().strip()
count = 0
index = 1
val = True
for i in range(1, min(len(s1), len(s2))):
	index = i
	if s1[-i] != s2[-i]:
		val = False
		break
if val:
	if s1[-min(len(s1), len(s2))] != s2[-min(len(s1), len(s2))]:
		count = 2 + abs(len(s1) - len(s2))
	else:
		count = abs(len(s1) - len(s2))
else:
	count = len(s1) + len(s2) - 2 * (index - 1)
print(count)


i = input
(a, b) = (i(), i())
r = len(a) + len(b)
for (x, y) in zip(a[::-1], b[::-1]):
	if x != y:
		break
	r -= 2
print(r)


s = input()
t = input()
k = len(s)
m = len(t)
i = 0
while i < k and i < m:
	if s[k - 1 - i] == t[m - 1 - i]:
		i += 1
	else:
		break
print(k + m - 2 * i)


s = input()
t = input()
ss = s[-1::-1]
tt = t[-1::-1]
sl = len(s)
tl = len(t)
if sl > tl:
	l = tl
else:
	l = sl
c = 0
for i in range(l):
	if ss[i] == tt[i]:
		c += 1
	else:
		break
print(sl + tl - c * 2)


import sys
import os
from io import IOBase, BytesIO

def main():
	s = list(input())
	t = list(input())
	s.reverse()
	t.reverse()
	ans = 0
	while len(s) > len(t):
		s.pop()
		ans += 1
	while len(t) > len(s):
		ans += 1
		t.pop()
	idx = 0
	for i in range(len(t) - 1, -1, -1):
		if s[i] != t[i]:
			idx = len(t) - i
	ans += 2 * idx
	print(ans)
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		py2 = round(0.5)
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2 == 1:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def get_array():
	return list(map(int, sys.stdin.readline().split()))

def get_ints():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline().strip()
main()


s = list(input())
t = list(input())
while s and t and (s[-1] == t[-1]):
	s.pop()
	t.pop()
print(len(s) + len(t))


(*a,) = reversed(input())
(*b,) = reversed(input())
counter = 0
for (i, j) in zip(a, b):
	if i != j:
		break
	counter += 1
print(len(a) + len(b) - counter * 2)


a = input()
b = input()
i = 1
while i < min(len(a), len(b)) + 1:
	if a[i * -1] != b[i * -1]:
		break
	i += 1
print(len(a) + len(b) - 2 * (i - 1))


s = input()
s1 = input()
s = s[::-1]
s1 = s1[::-1]
ans = -1
for i in range(min(len(s), len(s1))):
	if s[i] != s1[i]:
		ans = i
		break
if ans == -1:
	ans = min(len(s), len(s1))
print(len(s) + len(s1) - ans * 2)


s = list(input())
t = list(input())
s.reverse()
t.reverse()
ans = 0
if s[0] != t[0]:
	ans = len(s) + len(t)
else:
	cnt = 0
	for i in range(min(len(s), len(t))):
		if s[i] == t[i]:
			cnt += 1
		else:
			break
	ans = len(s) - cnt + (len(t) - cnt)
print(ans)


lst1 = list(input())
lst2 = list(input())
ans = 0
for i in range(-1, -min(len(lst1), len(lst2)) - 1, -1):
	if lst1[i] != lst2[i]:
		print(len(lst1) + len(lst2) - ans * 2)
		exit()
	else:
		ans += 1
print(len(lst1) + len(lst2) - ans * 2)


s = input()
t = input()
(m, n) = (len(s), len(t))
a = -1
while -a <= m and -a <= n:
	if s[a] == t[a]:
		a -= 1
	else:
		break
c = -a - 1
r = m + n - 2 * c
print(r)


from sys import stdin
s = stdin.readline()
t = stdin.readline()
matched = 0
for i in range(min(len(s), len(t))):
	if s[len(s) - i - 1] == t[len(t) - i - 1]:
		matched += 1
	else:
		break
print(len(s) - matched + len(t) - matched)


R = lambda : map(int, input().split())
str_one = input()
str_two = input()
rev_one = str_one[::-1]
rev_two = str_two[::-1]
i = 0
n_one = len(rev_one)
n_two = len(rev_two)
while i < n_one and i < n_two:
	if rev_one[i] == rev_two[i]:
		i += 1
	else:
		break
ans = 0
ans = abs(n_one - i) + abs(n_two - i)
print(ans)


s1 = input()
s2 = input()
l = min(len(s1), len(s2))
same = 0
for i in range(-1, -l - 1, -1):
	if s1[i] == s2[i]:
		same += 1
	else:
		break
print(len(s1) + len(s2) - 2 * same)


s = str(input())
t = str(input())
max_suffix = 0
for i in range(min(len(s), len(t))):
	if s[len(s) - i - 1] == t[len(t) - i - 1]:
		max_suffix += 2
	else:
		break
print(len(s) + len(t) - max_suffix)


a = input()
b = input()
(p, q) = (len(a), len(b))
t = 0
if p > q:
	r = p
	for i in range(q - 1, -1, -1):
		if b[i] == a[r - 1]:
			t = t + 2
			r = r - 1
		else:
			break
	print(p + q - t)
else:
	r = q
	for i in range(p - 1, -1, -1):
		if a[i] == b[r - 1]:
			t = t + 2
			r = r - 1
		else:
			break
	print(p + q - t)


(s, t) = (input()[::-1], input()[::-1])

def task(s, t):
	for i in range(min(len(s), len(t))):
		if s[i] != t[i]:
			return i
	return min(len(s), len(t))
if task(s, t) == min(len(s), len(t)):
	print(abs(len(s) - len(t)))
else:
	print(len(s) + len(t) - 2 * task(s, t))


s = input()
t = input()
(i, j, count) = (len(s) - 1, len(t) - 1, 0)
while i >= 0 and j >= 0 and (s[i] == t[j]):
	count += 1
	(i, j) = (i - 1, j - 1)
print(len(s) - count + len(t) - count)


a = input()
b = input()
n = 0
if len(a) < len(b):
	t = len(a)
else:
	t = len(b)
for i in range(t):
	if a[len(a) - i - 1] == b[len(b) - i - 1]:
		n += 2
	else:
		break
print(len(a) + len(b) - n)


s1 = str(input())
s2 = str(input())
s1_1 = s1[::-1]
s2_1 = s2[::-1]
k = 0
for i in range(min(len(s1), len(s2))):
	if s1_1[i] == s2_1[i]:
		k += 1
	else:
		break
print(len(s1) + len(s2) - 2 * k)


a = input()
b = input()
i = len(a) - 1
j = len(b) - 1
while a[i] == b[j]:
	i = i - 1
	j = j - 1
	if i < 0 or j < 0:
		break
print(i + j + 2)


s = input()
t = input()
n = len(s + t)
m = min(len(s), len(t))
s = s[::-1]
t = t[::-1]
ans = 0
for i in range(m):
	if s[i] != t[i]:
		break
	ans += 2
print(n - ans)


s = input()
t = input()
m = min(len(s), len(t))
for i in range(1, m + 1):
	if s[-i] != t[-i]:
		print(len(s) - (i - 1) + len(t) - (i - 1))
		break
else:
	print(len(s) - m + len(t) - m)


a = input()
b = input()
i = len(a) - 1
j = len(b) - 1
c = 0
if i < 0 or j < 0:
	print(i + j + 2)
else:
	while i >= 0 and j >= 0 and (a[i] == b[j]):
		c += 1
		i -= 1
		j -= 1
	print(i + j + 2)


def inline():
	return [int(e) for e in input().split()]

def outline(l):
	for e in l:
		print(e, end=' ')
	print()

def outlist(l):
	for e in l:
		print(e)
first = input()
second = input()
same = 0
while True:
	i = len(first) - same - 1
	j = len(second) - same - 1
	if i >= 0 and j >= 0 and (first[i] == second[j]):
		same += 1
	else:
		break
print(len(first) + len(second) - 2 * same)


s = input()
t = input()
i = 0
while i < min(len(s), len(t)):
	if s[-1 - i] != t[-1 - i]:
		break
	i += 1
print(len(s) + len(t) - 2 * i)


a = list(input())
b = list(input())
x = len(a)
y = len(b)
n = min(x, y)
i = 1
while i <= n:
	if a[-1 * i] == b[-1 * i]:
		i += 1
	else:
		break
print(y + x - 2 * i + 2)


s1 = list(str(input()))
s2 = list(str(input()))
l1 = len(s1) - 1
l2 = len(s2) - 1
count = 0
while l1 >= 0 and l2 >= 0:
	if s1[l1] == s2[l2]:
		count += 1
		l1 -= 1
		l2 -= 1
	else:
		break
l1 += 1
l2 += 1
print(l1 + l2)


s = input()
t = input()
l = len(s)
l2 = len(t)
ans = l + l2
for i in range(min(l, l2)):
	if s[-1 - i] == t[-1 - i]:
		ans -= 2
	else:
		break
print(ans)


s = input()
t = input()
i = 1
cnt = 0
while i <= min(len(s), len(t)) and s[-i] == t[-i]:
	cnt += 2
	i += 1
print(len(s) + len(t) - cnt)


s = list(input())
t = list(input())
s.reverse()
t.reverse()
ls = len(s)
lt = len(t)
ans = ls + lt
for i in range(min(ls, lt)):
	if s[i] == t[i]:
		ans -= 2
	else:
		break
print(ans)


s = input()[::-1]
t = input()[::-1]
l = (len(s), len(t))
(i, n) = (0, min(l))
while i < n:
	if s[i] != t[i]:
		break
	i += 1
print(sum(l) - i - i)


s1 = input()
s2 = input()
a = len(s1) - 1
b = len(s2) - 1
res = a + b + 2
while True:
	if s1[a] == s2[b] and a >= 0 and (b >= 0):
		a -= 1
		b -= 1
	else:
		break
print(a + b + 2)


s = input()
s = s[::-1]
t = input()
t = t[::-1]
p = 0
for i in range(min(len(s), len(t))):
	if s[i] == t[i]:
		p += 1
		continue
	else:
		break
i -= 1
print(len(s) + len(t) - 2 * p)


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
l1 = z()
l2 = z()
t1 = len(l1)
t2 = len(l2)
ans = 0
while True:
	if l1[t1 - 1] == l2[t2 - 1]:
		ans += 1
		t1 -= 1
		t2 -= 1
		if t1 <= 0 or t2 <= 0:
			t1 = 0
			t2 = 0
			break
	else:
		break
print(len(l1) + len(l2) - 2 * ans)


a = input()
b = input()
c = 0
for i in range(min(len(a), len(b))):
	if a[-1 - i] == b[-1 - i]:
		c += 1
	else:
		break
print(len(a) + len(b) - 2 * c)


s1 = list(input(''))
s2 = list(input(''))
s1.reverse()
s2.reverse()
paisi = 0
for i in range(min(len(s1), len(s2))):
	if s1[i] == s2[i]:
		paisi += 1
	else:
		break
if paisi == 0:
	print(len(s1) + len(s2))
else:
	print(len(s1) + len(s2) - paisi * 2)


n = input()
m = input()
a = len(n)
b = len(m)
c = 0
for i in range(min(a, b)):
	if n[-1] != m[-1]:
		print(a + b)
		break
	elif n[-(i + 1)] == m[-(i + 1)]:
		c = c + 1
		if c == min(a, b):
			print(max(a, b) - c)
	else:
		print(a - c + b - c)
		break


a = input()
b = input()
i = len(a) - 1
j = len(b) - 1
com = ''
while i >= 0 and j >= 0:
	if a[i] == b[j]:
		com += a[i]
	else:
		break
	i -= 1
	j -= 1
print(len(a) + len(b) - len(com) * 2)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def solve():
	a = inp()
	b = inp()
	k1 = len(a)
	k2 = len(b)
	k = min(k1, k2)
	c = 0
	for i in range(-1, -k - 1, -1):
		if a[i] == b[i]:
			c += 1
		else:
			break
	print(k1 + k2 - 2 * c)
solve()


import os
import io
s = list(input())[::-1]
t = list(input())[::-1]
pos = 0
tot = max(len(s), len(t)) - min(len(s), len(t))
while pos < min(len(s), len(t)):
	if s[pos] != t[pos]:
		tot = len(s) - pos + (len(t) - pos)
		break
	pos += 1
print(tot)


s = ''.join(reversed(input()))
t = ''.join(reversed(input()))
n = min(len(s), len(t))
i = 0
a = 0
while i < n:
	if s[i] != t[i]:
		break
	else:
		a += 1
	i += 1
print(len(s) + len(t) - 2 * a)


s1 = input()
s2 = input()
l1 = len(s1)
l2 = len(s2)
c = 0
i = l1 - 1
j = l2 - 1
while i >= 0 and j >= 0:
	if s1[i] == s2[j]:
		c = c + 2
	else:
		break
	i = i - 1
	j = j - 1
print(l1 + l2 - c)


s = input()[::-1]
t = input()[::-1]
p = len(s)
q = len(t)
f = min(p, q)
for i in range(f):
	if s[i] != t[i]:
		break
	if s[i] == t[i]:
		p = p - 1
		q = q - 1
print(p + q)


value = input()
value1 = input()
length = len(value)
length1 = len(value1)
temp = 0
while True:
	l = length - temp - 1
	m = length1 - temp - 1
	if l >= 0 and m >= 0 and (value[l] == value1[m]):
		temp += 1
	else:
		break
print(length + length1 - 2 * temp)


s1 = input()[::-1]
s2 = input()[::-1]
fg = 0
for i in range(min(len(s1), len(s2))):
	if s1[i] != s2[i]:
		fg = 1
		break
if fg == 0:
	exit(print(abs(len(s1) - len(s2))))
print(len(s1) + len(s2) - 2 * i)


s1 = input()
s2 = input()
l1 = len(s1)
l2 = len(s2)
l = min(l1, l2)
(i, j, f) = (0, 0, 1)
if len(s1) == 0:
	print(len(s2))
elif len(s2) == 0:
	print(len(s2))
elif s1[-1] != s2[-1]:
	print(l1 + l2)
else:
	while f:
		i += 1
		if i == l + 1:
			break
		elif s1[l1 - i] != s2[l2 - i]:
			f = 0
	i -= 1
	print(l1 + l2 - 2 * i)


s = input()
t = input()
p = s[::-1]
q = t[::-1]
n = len(s) + len(t)
cnt = 0
for i in range(min(len(s), len(t))):
	if p[i] == q[i]:
		cnt += 1
	else:
		break
print(n - 2 * cnt)


from sys import stdin, stdout
a = stdin.readline().strip()[::-1]
b = stdin.readline().strip()[::-1]
ans = 0
n = min(len(a), len(b))
for i in range(n):
	if a[i] == b[i]:
		ans = i + 1
	else:
		break
print(len(b) + len(a) - 2 * ans)


first_string = input()
second_string = input()
first_index = len(first_string) - 1
second_index = len(second_string) - 1
while first_index >= 0 and second_index >= 0:
	if first_string[first_index] != second_string[second_index]:
		break
	else:
		first_index -= 1
		second_index -= 1
count = first_index + 1 + second_index + 1
print(count)


t = input()
s = input()
if len(s) > len(t):
	(t, s) = (s, t)
d = 0
for i in range(1, len(s) + 1):
	if s[-i] != t[-i]:
		break
	d += 1
print(len(s) + len(t) - 2 * d)


import os
import sys
import math
import collections
import cmath

def mp():
	return map(int, input().split())

def inp():
	return input()
a = inp()
b = inp()
a1 = a[::-1]
b1 = b[::-1]
count = 0
i = 0
while i < len(a) and i < len(b):
	if a1[i] == b1[i]:
		count += 1
		i += 1
	else:
		break
print(len(a) + len(b) - 2 * count)


a = list(input())
b = list(input())
while a and b and (a[-1] == b[-1]):
	a.pop()
	b.pop()
print(len(a + b))


s1 = input()
s2 = input()
s1 = s1[::-1]
s2 = s2[::-1]
n = len(s1)
m = len(s2)
(i, j, ans) = (0, 0, 0)
while i < n and j < m:
	if s1[i] != s2[j]:
		break
	ans += 1
	i += 1
	j += 1
if n >= ans:
	out = n - ans
if m >= ans:
	out += m - ans
print(out)


str1 = input()
str2 = input()
(l1, l2) = (len(str1), len(str2))
same = 0
while l1 > 0 and l2 > 0:
	if str1[l1 - 1] == str2[l2 - 1]:
		same += 1
		l1 -= 1
		l2 -= 1
	else:
		break
print(len(str1) - same + len(str2) - same)


s = input()
n = input()
a = len(s)
b = len(n)
x = 0
for i in range(min(a, b)):
	if s[a - 1 - i] != n[b - 1 - i]:
		break
	x += 1
print(a - x + b - x)


s = input()[::-1]
t = input()[::-1]
i = 0
while i < min(len(s), len(t)) and s[i] == t[i]:
	i += 1
print(len(s) - i + len(t) - i)


(s, t) = (input(), input())
s_len = len(s)
t_len = len(t)
w = 0
while True:
	if s_len >= w + 1 <= t_len and s[-(w + 1)] == t[-(w + 1)]:
		w += 1
	else:
		break
print(s_len + t_len - 2 * w)


(s, t) = (input(), input())
for i in range(max(len(s), len(t))):
	if i == min(len(s), len(t)) or s[-i - 1] != t[-i - 1]:
		print(len(s) + len(t) - 2 * i)
		break
else:
	print(0)


t = input()
s = input()
k = 0
if len(s) > len(t):
	x = len(s) - len(t)
	s = s[x:]
else:
	x = len(t) - len(s)
	t = t[x:]
for i in range(len(s), 0, -1):
	if s[i - 1] != t[i - 1]:
		k = i * 2
		break
print(k + x)


a = input()
b = input()
a = a[::-1]
b = b[::-1]
x = min(len(a), len(b))
for i in range(min(len(a), len(b))):
	if a[i] != b[i]:
		x = i
		break
moves = len(a) - x + (len(b) - x)
print(moves)


s = input()
t = input()
done = 1
(lent, lens) = (len(t), len(s))
k = lens if lens <= lent else lent
l = lens if lens > lent else lent
for x in range(1, k + 1):
	if s[-x] not in t[-x]:
		print(lens + lent - x - x + 2)
		done = 0
		break
if done > 0:
	print(l - k)


TN = 1

def solution():
	s = input()
	t = input()
	ls = len(s)
	lt = len(t)
	if ls > lt:
		lk = lt
		t = ' ' * (ls - lt) + t
		lt = ls
	else:
		lk = ls
		s = ' ' * (lt - ls) + s
		ls = lt
	i = lt - 1
	cnt = 0
	while i >= 0 and s[i] == t[i]:
		cnt += 1
		i -= 1
	ans = i
	if ans == lt - 1:
		print(ls + lk)
	else:
		print(ls - 2 * cnt + lk)
while TN != 0:
	solution()
	TN -= 1


s1 = input()
s2 = input()
(i, j) = (len(s1) - 1, len(s2) - 1)
while i >= 0 and j >= 0 and (s1[i] == s2[j]):
	i -= 1
	j -= 1
ans = len(s1) + len(s2) - 2 * (len(s1) - i - 1)
print(ans)


a = list(input())
b = list(input())
a = a[::-1]
b = b[::-1]
i = 0
while i < min(len(a), len(b)):
	if a[i] == b[i]:
		i += 1
	else:
		break
print(len(a) + len(b) - 2 * i)


one = input()
two = input()
if len(two) < len(one):
	(one, two) = (two, one)
for i in range(len(one) - 1, -1, -1):
	other = two[i + len(two) - len(one)]
	if one[i] != other:
		end = len(one) - i - 1
		print(i + 1 + len(two) - end)
		break
else:
	print(len(two) - len(one))


a = input()
b = input()
count = 0
aend = len(a) - 1
bend = len(b) - 1
for i in range(min(len(a), len(b)) - 1, -1, -1):
	if a[aend] == b[bend]:
		aend -= 1
		bend -= 1
		count += 1
	else:
		break
bk = len(b) - count
ak = len(a) - count
print(bk + ak)


s1 = input()
s2 = input()
x1 = len(s1)
x2 = len(s2)
s1 = s1[::-1]
s2 = s2[::-1]
col = 0
for i in range(min(len(s1), len(s2))):
	if s1[i] == s2[i]:
		col += 1
	else:
		break
print(len(s1) + len(s2) - col * 2)


s1 = input()
s2 = input()
i = 1
j = 1
while s1[-i] == s2[-j]:
	i += 1
	j += 1
	if i > len(s1) or j > len(s2):
		break
i -= 1
j -= 1
print(len(s1) - i + len(s2) - j)


def solve(a, b):
	i = len(a)
	j = len(b)
	while a[i - 1] == b[j - 1] and i > 0 and (j > 0):
		i -= 1
		j -= 1
	return i + j
a = str(input())
b = str(input())
print(solve(a, b))


a = input()
b = input()
la = len(a)
lb = len(b)
ans = 0
if la == 0 or lb == 0:
	print(la + lb)
elif a[la - 1] != b[lb - 1]:
	print(la + lb)
else:
	m = min(la, lb)
	for i in range(m):
		if a[la - i - 1] == b[lb - i - 1]:
			ans = ans + 1
		else:
			break
	print(la + lb - ans - ans)


s1 = input()[::-1]
s2 = input()[::-1]
p1 = 0
p2 = 0
tamEquals = 0
while p1 < len(s1) and p2 < len(s2):
	if s1[p1] != s2[p2]:
		break
	tamEquals += 1
	p1 += 1
	p2 += 1
print(len(s1) + len(s2) - tamEquals * 2)


import math
s = input()
t = input()
i = len(s) - 1
j = len(t) - 1
c = 0
while i >= 0 and j >= 0 and (s[i] == t[j]):
	i -= 1
	j -= 1
if i == -1 or j == -1:
	c = len(s) + len(t)
else:
	c = i + j + 2
print(i + j + 2)


s = input()
t = input()
ti = len(t)
si = len(s)
n = min(ti, si)
for i in range(1, n + 1):
	if t[-i] != s[-i]:
		break
	ti -= 1
	si -= 1
print(ti + si)


(str1, str2) = (input(), input())
(str1, str2) = (str1[::-1], str2[::-1])
(len1, len2) = (len(str1), len(str2))
cnt = 0
for i in range(0, min(len1, len2)):
	if str1[i] != str2[i]:
		break
	cnt += 1
print(len1 + len2 - cnt * 2)


a = input()
b = input()
if len(b) > len(a):
	(a, b) = (b, a)
ans = -1
for i in range(len(b)):
	if b[-1 - i] != a[-1 - i]:
		ans = len(a) + len(b) - 2 * i
		break
if ans == -1:
	print(len(a) - len(b))
else:
	print(ans)


def delfromleft(s, t):
	d = 0
	i = len(s) - 1
	if s[len(s) - 1] != t[len(t) - 1]:
		return len(s) + len(t)
	else:
		for j in range(len(t) - 1, -1, -1):
			if s[i] == t[j]:
				d += 1
			else:
				break
			i = i - 1
	return abs(len(s) + len(t) - d * 2)
a = list(input())
b = list(input())
print(delfromleft(a, b))


a = str(input())
b = str(input())
k = 1
ans = 0
for i in range(min(len(a), len(b)) - 1, -1, -1):
	if a[len(a) - k] == b[len(b) - k]:
		ans += 2
	else:
		break
	k += 1
print(len(a) + len(b) - ans)


def solve():
	pass
s1 = input()
s2 = input()
total = 0

def intersect(s1, s2):
	return set(substrings(s1)) & set(substrings(s2))
i = len(s1) - 1
j = len(s2) - 1
while True:
	if s1[i] != s2[j] or i < 0 or j < 0:
		i += 1
		j += 1
		break
	i -= 1
	j -= 1
total = 0
if i == -1 and j == -1:
	total = len(s1) + len(s2)
elif i == -1 and j >= 0:
	total = len(s1) + j
elif j == -1 and i >= 0:
	total = len(s2) + i
elif i >= 0 and j >= 0:
	total = i + j
print(total)


s = input()
t = input()
a = ''
i = len(s) - 1
j = len(t) - 1
while i >= 0 and j >= 0:
	if s[i] != t[j]:
		break
	else:
		a += s[i]
	i -= 1
	j -= 1
if a == '':
	print(len(s) + len(t))
else:
	print(len(s) - len(a) + len(t) - len(a))


str1 = input()
str2 = input()
eq = 0
ind = -1
while len(str1) >= -ind and len(str2) >= -ind and (str1[ind] == str2[ind]):
	eq += 1
	ind -= 1
print(len(str1) + len(str2) - 2 * eq)


import sys
import math
aa = str(input())
bb = str(input())
cc = aa[::-1]
dd = bb[::-1]
con = 0
if cc[0] != dd[0]:
	print(len(aa) + len(bb))
else:
	for i in range(min(len(cc), len(dd))):
		if cc[i] == dd[i]:
			con += 1
		else:
			break
	print(len(aa) + len(bb) - 2 * con)


a = str(input())
b = str(input())
a = a[::-1]
b = b[::-1]
t = 0
for i in range(min(len(a), len(b))):
	if a[i] != b[i]:
		break
	else:
		t += 1
print(len(a) + len(b) - t - t)


s = input()
t = input()
k = len(s) + len(t)
m = 0
for (a, b) in zip(s[::-1], t[::-1]):
	if a == b:
		m += 2
	else:
		break
print(k - m)


def solve():
	s = input()[::-1]
	t = input()[::-1]
	same = 0
	for i in range(min(len(s), len(t))):
		if s[i] != t[i]:
			break
		same += 1
	print(len(s) + len(t) - 2 * same)
solve()


(s1, s2) = (input(), input())
tot_len = len(s1) + len(s2)
s1 = s1[::-1]
s2 = s2[::-1]
for (i, j) in zip(s1, s2):
	if i != j:
		break
	tot_len -= 2
print(tot_len)


x = input()
y = input()
x = x[::-1]
y = y[::-1]
maxn = 0
for i in range(min(len(x), len(y))):
	if x[i] != y[i]:
		break
	else:
		maxn += 1
print(len(x) + len(y) - maxn * 2)


(s, t) = (input(), input())
(ls, lt) = (len(s), len(t))
c = 0
while True:
	i = ls - c - 1
	j = lt - c - 1
	if i >= 0 and j >= 0 and (s[i] == t[j]):
		c += 1
	else:
		break
print(ls + lt - 2 * c)


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(100000000)
	threading.stack_size(40960000)
	thread = threading.Thread(target=main)
	thread.start()
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def main():
	a = si()
	b = si()
	n = min(len(a), len(b))
	aa = ''
	for i in range(len(a) - 1, len(a) - n - 1, -1):
		aa += a[i]
	bb = ''
	for i in range(len(b) - 1, len(b) - n - 1, -1):
		bb += b[i]
	pos = n
	for i in range(n):
		if aa[i] != bb[i]:
			pos = i
			break
	print(len(a) + len(b) - 2 * pos)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


x = input()
t = input()
xi = len(x) - 1
ti = len(t) - 1
same = 0
while xi >= 0 and ti >= 0:
	if x[xi] != t[ti]:
		break
	else:
		xi -= 1
		ti -= 1
		same += 2
print(len(x) + len(t) - same)


s = input()
t = input()
if len(s) > len(t):
	(s, t) = (t, s)
k = 0
q = True
ls = len(s)
lt = len(t)
while k < len(s):
	if s[ls - k - 1] != t[lt - k - 1]:
		print(lt + ls - 2 * k)
		q = False
		break
	k = k + 1
if q:
	print(lt - ls)


from sys import stdin

def get_length_of_max_suffix(s, t):
	ml = min(len(s), len(t))
	for i in range(1, ml + 1):
		if s[-i] != t[-i]:
			return i - 1
	return ml
s = stdin.readline()
t = stdin.readline()
print(len(s) + len(t) - 2 * get_length_of_max_suffix(s, t))


X1 = input()
X2 = input()
Count = 0
i = 1
while i <= len(X1) and i <= len(X2) and (X1[-i] == X2[-i]):
	Count += 2
	i += 1
print(len(X1) + len(X2) - Count)


def main():
	s = list(input())[::-1]
	t = list(input())[::-1]
	L = -1
	while L + 1 < len(s) and L + 1 < len(t) and (s[L + 1] == t[L + 1]):
		L += 1
	print(len(s) - (L + 1) + len(t) - (L + 1))
main()


from sys import stdin, stdout

def solve():
	s = stdin.readline().strip()
	t = stdin.readline().strip()
	sn = len(s)
	st = len(t)
	same_p = 0
	for i in range(1, min(sn, st) + 1):
		if s[-i] == t[-i]:
			same_p += 1
		else:
			break
	print(sn + st - same_p - same_p)
	pass
LOCAL_TEST = not __debug__
if LOCAL_TEST:
	infile = __file__.split('.')[0] + '-test.in'
	stdin = open(infile, 'r')
tcs = int(stdin.readline().strip()) if LOCAL_TEST else 1
t = 1
while t <= tcs:
	solve()
	t += 1


s = input()
t = input()
ss = s[::-1]
tt = t[::-1]
count = 0
for i in range(min(len(ss), len(tt))):
	if ss[i] == tt[i]:
		count += 1
	else:
		break
print(len(s) + len(t) - 2 * count)


s1 = input()
s2 = input()
i = len(s1) - 1
j = len(s2) - 1
while i >= 0 and j >= 0 and (s1[i] == s2[j]):
	i -= 1
	j -= 1
if i == -1 and j >= 0:
	print(j + 1)
elif i >= 0 and j == -1:
	print(i + 1)
else:
	print(i + j + 2)


s = input()
t = input()
if not s or not t:
	print(len(s) or len(t))
else:
	(p, q) = (len(s) - 1, len(t) - 1)
	while p >= 0 and q >= 0 and (s[p] == t[q]):
		p -= 1
		q -= 1
	print(p + q + 2)


s = input()
t = input()
z = 0
d = 0
while z >= 0:
	if len(s) - 1 - z >= 0 and len(t) - 1 - z >= 0:
		if s[len(s) - 1 - z] == t[len(t) - 1 - z]:
			z = z + 1
			d = d + 2
		else:
			break
	else:
		break
print(len(s) + len(t) - d)


(a, b) = (input(), input())
(p, q) = (len(a), len(b))
a = a[::-1]
b = b[::-1]
i = 0
while i < min(p, q) and a[i] == b[i]:
	i += 1
print(p + q - 2 * i)


s = input()
t = input()
ls = len(s)
lt = len(t)
c = 0
if ls > lt:
	x = ls - lt
	s = s[x:ls]
elif lt > ls:
	x = lt - ls
	t = t[x:lt]
s = s[::-1]
t = t[::-1]
for i in range(len(t)):
	if s[i] == t[i]:
		c = c + 1
	else:
		break
r = lt + ls - 2 * c
print(r)


arr1 = list()
arr2 = list()
arr1 = input()
arr2 = input()
n = 0
if len(arr1) == len(arr2):
	if arr1 == arr2:
		print(0)
	else:
		k = len(arr1) - 1
		if arr1[k] != arr2[k]:
			n = (k + 1) * 2
		else:
			while k >= 0 and arr1[k] == arr2[k]:
				k = k - 1
			n = (k + 1) * 2
		print(n)
elif len(arr1) > len(arr2):
	k = len(arr1) - len(arr2)
	arr1 = arr1[k:]
	n = k
	if arr1 == arr2:
		print(n)
	else:
		k = len(arr1) - 1
		if arr1[k] != arr2[k]:
			n = n + (k + 1) * 2
		else:
			while k >= 0 and arr1[k] == arr2[k]:
				k = k - 1
			n = n + (k + 1) * 2
		print(n)
elif len(arr1) < len(arr2):
	k = len(arr2) - len(arr1)
	arr2 = arr2[k:]
	n = k
	if arr1 == arr2:
		print(n)
	else:
		k = len(arr1) - 1
		if arr1[k] != arr2[k]:
			n = n + (k + 1) * 2
		else:
			while k >= 0 and arr1[k] == arr2[k]:
				k = k - 1
			n = n + (k + 1) * 2
		print(n)


(a, b) = (input(), input())
(i, j) = (len(a), len(b))
while i and j and (a[i - 1] == b[j - 1]):
	i -= 1
	j -= 1
print(i + j)


(a, b) = (input(), input())
(f, n, m) = (0, len(a), len(b))
for x in range(min(n, m)):
	if a[-(x + 1)] != b[-(x + 1)]:
		f = 1
		break
if f == 1:
	print(n + m - 2 * x)
else:
	print(abs(m - n))


a = input()
b = input()
l = min(len(a), len(b))
check = 0
for i in range(l):
	if a[len(a) - 1 - i] != b[len(b) - 1 - i]:
		break
	check += 1
print(len(a) - check + (len(b) - check))


s1 = input()
s2 = input()
c = 0
a = len(s1)
b = len(s2)
(k, l) = (a - 1, b - 1)
if s1 == s2:
	print(0)
else:
	while k >= 0 and l >= 0:
		if s1[k] != s2[l]:
			break
		else:
			c = c + 1
		k = k - 1
		l = l - 1
	if c == 0:
		print(a + b)
	else:
		print(a + b - 2 * c)


a = list(input())
b = list(input())
if len(a) > len(b):
	(a, b) = (b, a)
j = len(b) - 1
ans = 0
for i in range(len(a) - 1, -1, -1):
	if a[i] == b[j]:
		ans += 1
		j -= 1
	else:
		print(len(a) - 2 * ans + len(b))
		exit()
if j != -1:
	print(abs(len(b) - len(a)))
else:
	print(0)


T_ON = 0
DEBUG_ON = 1
MOD = 998244353

def solve():
	s = input()
	t = input()
	if s == t:
		print(0)
		return
	i = 0
	while i < min(len(s), len(t)):
		j = -1 - i
		if s[j] != t[j]:
			break
		i += 1
	print(len(s) + len(t) - 2 * i)

def main():
	T = read_int() if T_ON else 1
	for i in range(T):
		solve()

def debug(*xargs):
	if DEBUG_ON:
		print(*xargs)
from collections import *
import math
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def read_int():
	return int(input())

def read_ints():
	return list(map(int, input().split()))

def print_nums(nums):
	print(' '.join(map(str, nums)))

def YES():
	print('YES')

def Yes():
	print('Yes')

def NO():
	print('NO')

def No():
	print('No')

def First():
	print('First')

def Second():
	print('Second')

def fib(n):
	(a, b) = (0, 1)
	for _ in range(n):
		(a, b) = (b, a + b)
	return a

def fib_ns(n):
	assert n >= 1
	f = [0 for _ in range(n + 1)]
	f[0] = 0
	f[1] = 1
	for i in range(2, n + 1):
		f[i] = f[i - 1] + f[i - 2]
	return f

def fib_to_n(n):
	f = []
	(a, b) = (0, 1)
	while a <= n:
		f.append(a)
		(a, b) = (b, a + b)
	return f

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def xgcd(a, b):
	(x0, x1, y0, y1) = (0, 1, 1, 0)
	while a != 0:
		((q, a), b) = (divmod(b, a), a)
		(y0, y1) = (y1, y0 - q * y1)
		(x0, x1) = (x1, x0 - q * x1)
	return (b, x0, y0)

def lcm(a, b):
	d = gcd(a, b)
	return a * b // d

def is_even(x):
	return x % 2 == 0

def is_odd(x):
	return x % 2 == 1

def modinv(a, m):
	(g, x, _) = xgcd(a, m)
	if g != 1:
		raise Exception('gcd(a, m) != 1')
	return x % m

def mod_add(x, y):
	x += y
	while x >= MOD:
		x -= MOD
	while x < 0:
		x += MOD
	return x

def mod_mul(x, y):
	return x * y % MOD

def mod_pow(x, y):
	if y == 0:
		return 1
	if y % 2:
		return mod_mul(x, mod_pow(x, y - 1))
	p = mod_pow(x, y // 2)
	return mod_mul(p, p)

def mod_inv(y):
	return mod_pow(y, MOD - 2)

def mod_div(x, y):
	return mod_mul(x, mod_inv(y))

def is_prime(n):
	if n == 1:
		return False
	for i in range(2, int(n ** 0.5) + 1):
		debug(n, i)
		if n % i == 0:
			return False
	return True

def gen_primes(n):
	P = [True for _ in range(n + 1)]
	P[0] = P[1] = False
	for i in range(int(n ** 0.5) + 1):
		if P[i]:
			for j in range(2 * i, n + 1, i):
				P[j] = False
	return P

def is_lucky(n):
	return set(list(str(n))).issubset({'4', '7'})
main()


def find(a, b):
	a = a[::-1]
	b = b[::-1]
	(len1, len2) = (len(a), len(b))
	length = min(len1, len2)
	count = 0
	for i in range(length):
		if a[i] == b[i]:
			count += 1
		else:
			break
	return len1 + len2 - 2 * count
a = input()
b = input()
print(find(a, b))


a = input()[::-1]
b = input()[::-1]
same = 0
for i in range(min(len(a), len(b))):
	if a[i] != b[i]:
		break
	else:
		same += 1
print(len(a) - same + len(b) - same)


s = input().strip()
t = input().strip()
if len(s) > len(t):
	x = s
	s = t
	t = x
if s == t:
	print(0)
elif s == t[len(t) - len(s):]:
	print(len(t) - len(s))
else:
	for i in range(1, len(t) + 1):
		if s[-i] != t[-i]:
			break
	print(len(s) - i + 1 + len(t) - i + 1)


def f(s, t):
	count = 0
	i = 1
	if s == t:
		return 0
	else:
		while i <= len(s) and i <= len(t) and (s[len(s) - i] == t[len(t) - i]):
			i += 1
		return len(s) - i + 1 + len(t) - i + 1
s = input()
t = input()
print(f(s, t))


a = input()
b = input()
jc = -1
while a[jc] == b[jc]:
	jc -= 1
	if jc == 0 or abs(jc) > len(a) or abs(jc) > len(b):
		break
if jc != 0:
	jc += 1
	jc *= -1
	print(len(a) + len(b) - 2 * jc)
else:
	print('0')


s = input()
t = input()
if s == t:
	print('0')
elif s[-1:] != t[-1:]:
	print(len(s) + len(t))
else:
	moves = 0
	if len(s) > len(t):
		moves += len(s) - len(t)
		s = s[-len(t):]
	elif len(t) > len(s):
		moves += len(t) - len(s)
		t = t[-len(s):]
	while len(s) > 1:
		mid = len(s) // 2
		if s[mid:] != t[mid:]:
			moves += len(s[:mid]) * 2
			s = s[mid:]
			t = t[mid:]
		else:
			s = s[:mid]
			t = t[:mid]
	if s != t:
		moves += 2
	print(moves)


s = input()
t = input()
sl = len(s)
tl = len(t)
NoOfSteps = sl + tl
flag = 0
if sl < tl:
	for i in range(1, sl + 1):
		if s[sl - i] == t[tl - i]:
			NoOfSteps -= 2
		else:
			flag = 1
			print(NoOfSteps)
			break
else:
	for i in range(1, tl + 1):
		if s[sl - i] == t[tl - i]:
			NoOfSteps -= 2
		else:
			flag = 1
			print(NoOfSteps)
			break
if flag == 0:
	print(NoOfSteps)


n = input()
s = input()
n = n[::-1]
s = s[::-1]
slen = len(s)
nlen = len(n)
i = 0
count = 0
while i < min(len(s), len(n)):
	if n[i] == s[i]:
		count += 1
		i += 1
	else:
		break
leng = len(s[count:]) + len(n[count:])
print(leng)


s = input()
t = input()
if s == t:
	print(0)
else:
	ind = -1
	ls = len(s)
	lt = len(t)
	r = 0
	for i in range(min(ls, lt)):
		if t[ind] != s[ind]:
			print(ls + lt - (abs(ind) - 1) * 2)
			r = 1
			break
		ind -= 1
	if r == 0:
		print(ls + lt - (abs(ind) - 1) * 2)


l = list(input())
k = list(input())
r = len(l)
t = len(k)
o = max(r, t)
c = 0
while r >= 1 and t >= 1 and (k[t - 1] == l[r - 1]):
	r -= 1
	t -= 1
print(r + t)


x = input()[::-1]
y = input()[::-1]
m = min(len(x), len(y))
s = len(x) + len(y)
for i in range(m):
	if x[i] == y[i]:
		s = s - 2
	else:
		break
print(s)


s = input()
t = input()
s = s[::-1]
t = t[::-1]
k = 0
while s[k] == t[k]:
	k += 1
	if k == len(s) or k == len(t):
		break
print(len(s) + len(t) - 2 * k)


s = input()
t = input()
cnt = abs(len(s) - len(t))
if len(s) > len(t):
	s = s[len(s) - len(t):]
else:
	t = t[len(t) - len(s):]
for i in range(len(s) - 1, -1, -1):
	if s[i] != t[i]:
		print(2 * (i + 1) + cnt)
		exit(0)
print(cnt)


a = list(input())
b = list(input())
a.reverse()
b.reverse()
count = 0
for i in range(min(len(a), len(b))):
	if a[i] == b[i]:
		count += 1
	else:
		break
res = len(a) - count + len(b) - count
print(res)


(w1, w2) = (input()[::-1], input()[::-1])
neq = 0
while neq < min(len(w1), len(w2)) and w1[neq] == w2[neq]:
	neq += 1
print(len(w1) + len(w2) - 2 * neq)


from sys import stdin, stdout
import bisect
import math
from collections import Counter

def st():
	return list(stdin.readline().strip())

def inp():
	return int(stdin.readline())

def li():
	return list(map(int, stdin.readline().split()))

def mp():
	return map(int, stdin.readline().split())

def pr(n):
	stdout.write(str(n) + '\n')

def soe(limit):
	l = [1] * (limit + 1)
	prime = []
	for i in range(2, limit + 1):
		if l[i]:
			for j in range(i * i, limit + 1, i):
				l[j] = 0
	for i in range(2, limit + 1):
		if l[i]:
			prime.append(i)
	return prime

def segsoe(low, high):
	limit = int(high ** 0.5) + 1
	prime = soe(limit)
	n = high - low + 1
	l = [0] * (n + 1)
	for i in range(len(prime)):
		lowlimit = low // prime[i] * prime[i]
		if lowlimit < low:
			lowlimit += prime[i]
		if lowlimit == prime[i]:
			lowlimit += prime[i]
		for j in range(lowlimit, high + 1, prime[i]):
			l[j - low] = 1
	for i in range(low, high + 1):
		if not l[i - low]:
			if i != 1:
				print(i)

def power(a, n):
	r = 1
	while n:
		if n & 1:
			r = r * a
			n = n - 1
		else:
			a = a * a
			n = n >> 1
	return r

def solve():
	s = input()
	c = 0
	t = input()
	(i, j) = (len(s) - 1, len(t) - 1)
	while i >= 0 and j >= 0:
		if s[i] != t[j]:
			break
		else:
			c += 1
		i -= 1
		j -= 1
	if c == 0:
		print(len(s) + len(t))
	else:
		print(len(s) + len(t) - 2 * c)
for _ in range(1):
	solve()


s = list(reversed(input()))
t = list(reversed(input()))
i = 0
while i < len(s) and i < len(t) and (s[i] == t[i]):
	i += 1
print(len(s) - i + len(t) - i)


def match(s, t):
	c = 0
	i = 0
	while i < len(t) and t[-i - 1] == s[-i - 1]:
		c += 1
		i += 1
	return c
s = input()
t = input()
c = 0
if len(t) <= len(s):
	c = match(s, t)
else:
	c = match(t, s)
print(len(s) + len(t) - 2 * c)


(a, b) = (input()[::-1], input()[::-1])
i = 0
r = 0
while i < len(a) and i < len(b) and (a[i] == b[i]):
	r += 2
	i += 1
print(len(a) + len(b) - r)


(s, t) = (input(), input())
(x, flag) = (min(len(s), len(t)), 0)
for i in range(1, x + 1):
	if s[-i] == t[-i]:
		continue
	else:
		flag = 1
		break
if flag == 0:
	print(len(s) - i + len(t) - i)
else:
	print(len(s) - (i - 1) + (len(t) - (i - 1)))


x = input()
y = input()
(a, b) = (len(x), len(y))
q = min(a, b)
(u1, u2) = (a - 1, b - 1)
w = 0
for i in range(q):
	if x[u1] == y[u2]:
		u1 -= 1
		u2 -= 1
		w += 1
	else:
		break
print(a + b - 2 * w)


(d, e) = (list(input()), list(input()))
while d and e and (d[-1] == e[-1]):
	d.pop()
	e.pop()
print(len(d + e))


s = input()
t = input()
slen = len(s)
tlen = len(t)
if slen < tlen:
	pass
else:
	(s, t) = (t, s)
	(slen, tlen) = (tlen, slen)
	pass
t = t[::-1][:slen]
s = s[::-1]
ind = 0
ans = 0
allsameflag = 1
for (a, b) in zip(s, t):
	if a != b:
		ans = tlen - ind + (slen - ind)
		allsameflag = 0
		break
	ind += 1
if allsameflag:
	ans = tlen - slen
print(ans)


s = list(input())
t = list(input())
s.reverse()
t.reverse()
for i in range(0, min(len(s), len(t))):
	if s[i] != t[i]:
		print(len(s) + len(t) - 2 * i)
		exit()
print(max(len(s), len(t)) - (i + 1))


s = input()
t = input()
if s[-1] != t[-1]:
	ans = len(s) + len(t)
else:
	same = 0
	for i in range(-1, -(min(len(s), len(t)) + 1), -1):
		if s[i] == t[i]:
			same += 1
		else:
			break
	ans = len(s) + len(t) - 2 * same
print(ans)


s1 = input()
s2 = input()
i = 0
for (el1, el2) in zip(s1[::-1], s2[::-1]):
	if el1 != el2:
		break
	i += 1
ans = len(s1) + len(s2) - 2 * i
print(ans)


(s, t) = (input(), input())
n = len(s) + len(t)
for (ch1, ch2) in zip(s[::-1], t[::-1]):
	if ch1 != ch2:
		break
	n -= 2
print(n)


s1 = input()
s2 = input()
if len(s1) == 0:
	print(len(s2))
elif len(s2) == 0:
	print(len(s1))
elif len(s1) == 0 and len(s2) == 0:
	print(0)
else:
	ans = 0
	x = list(reversed(s1))
	y = list(reversed(s2))
	if len(s1) == len(s2):
		if x[0] != y[0]:
			ans = ans + len(x) + len(y)
		else:
			match = 0
			for i in range(len(s2)):
				if x[i] == y[i]:
					match += 1
				else:
					break
			ans = ans + (len(s2) - match) * 2
	elif len(s1) <= len(s2):
		if x[0] != y[0]:
			ans = ans + len(x) + len(y)
		else:
			match = 0
			for i in range(len(s1)):
				if x[i] == y[i]:
					match += 1
				else:
					break
			ans = ans + (len(s1) - match) * 2 + len(s2) - len(s1)
	elif len(s1) >= len(s2):
		if x[0] != y[0]:
			ans = ans + len(x) + len(y)
		else:
			match = 0
			for i in range(len(s2)):
				if x[i] == y[i]:
					match += 1
				else:
					break
			ans = ans + (len(s2) - match) * 2 + len(s1) - len(s2)
	print(ans)


s = input()
t = input()
num = 0
n = len(s)
n2 = len(t)
temp = min(n, n2)
for i in range(temp):
	if s[n - i - 1] != t[n2 - i - 1]:
		break
	num += 1
print(max(n, n2) + temp - num * 2)


s = input()
t = input()
(m, n) = (len(s), len(t))
took = 0
while took < min(m, n) and s[-took - 1] == t[-took - 1]:
	took += 1
print(m + n - 2 * took)


s = input()
t = input()
s1 = len(s)
t1 = len(t)
m = min(s1, t1)
i = 1
while m:
	if s[s1 - i] != t[t1 - i]:
		break
	else:
		i += 1
		m -= 1
print(s1 + t1 - 2 * (i - 1))


s = input()[::-1]
s1 = input()[::-1]
w = min(len(s), len(s1))
i = 0
while i < w and s[i] == s1[i]:
	i += 1
print(len(s) + len(s1) - 2 * i)


a = input()
b = input()
le_a = len(a)
le_b = len(b)
n = le_a + le_b
count = 0
while True:
	ai = le_a - count - 1
	bi = le_b - count - 1
	if ai >= 0 and bi >= 0 and (a[ai] == b[bi]):
		count += 1
	else:
		break
print(n - count * 2)


s1 = input()
s2 = input()
l1 = list(s1)
l2 = list(s2)
len1 = len(l1)
len2 = len(l2)
i = len1 - 1
j = len2 - 1
k = 0
while i >= 0 and j >= 0:
	if l1[i] == l2[j]:
		k += 1
	else:
		break
	i -= 1
	j -= 1
moves = len1 - k + len2 - k
print(moves)


from math import *
s = input()
t = input()
i = 1
m = min(len(s), len(t))
while i <= m and s[-i] == t[-i]:
	i += 1
print(len(s) + len(t) - 2 * (i - 1))


s1 = input()
s2 = input()
x = len(s1)
y = len(s2)
i = x - 1
j = y - 1
c = 0
flag = True
while flag and i >= 0 and (j >= 0):
	if s1[i] != s2[j]:
		flag = False
		c += i + 1
		c += j + 1
		break
	i -= 1
	j -= 1
if flag:
	if i < 0:
		c += j + 1
	else:
		c += i + 1
print(c)


(a, b) = (input(), input())
res = abs(len(a) - len(b))
if len(a) > len(b):
	a = a[res:len(a)]
else:
	b = b[res:len(b)]
(i, j) = (0, 1)
while i < len(a):
	if a[i] != b[i]:
		res += 2 * j
		j = 1
	if a[i] == b[i]:
		j += 1
	i += 1
print(res)


def moves(s1, s2):
	tot = len(s1) + len(s2)
	count = 0
	i = -1
	while len(s1) + i >= 0 and len(s2) + i >= 0:
		if s1[i] != s2[i]:
			break
		count += 1
		i -= 1
	return len(s1) + len(s2) - 2 * count
s1 = input()
s2 = input()
print(moves(s1, s2))


s = list(input())
t = list(input())
count = 0
for i in range(-1, -len(s) - 1, -1):
	if len(t) >= abs(i) and s[i] == t[i]:
		count += 1
	else:
		break
print(len(s) - count + len(t) - count)


a = input()
b = input()
c = int(len(a))
d = int(len(b))
f = int(0)
if c >= d:
	if d == 1 and c == 2:
		if b[-1] == a[-1]:
			print(int(1))
		else:
			print(int(3))
	else:
		for i in range(1, d + 1):
			if a[-i] == b[-i]:
				f += 1
			elif a[-i] != b[-i]:
				break
		print(int(int(c + d) - int(2 * f)))
elif c < d:
	if c == 1 and d == 2:
		if a[-1] == b[-1]:
			print(int(1))
		else:
			print(int(3))
	else:
		for j in range(1, c + 1):
			if a[-j] == b[-j]:
				f += 1
			elif a[-j] != b[-j]:
				break
		print(int(int(c + d) - int(2 * f)))


s = input()
c = input()
ls = len(s)
lc = len(c)
for i in range(min(ls, lc)):
	if s[ls - i - 1] != c[lc - i - 1]:
		break
else:
	i += 1
print(ls - i + lc - i)


n = input()
m = input()
i = len(n) - 1
j = len(m) - 1
if n == m:
	print(0)
else:
	p = 0
	while True:
		if n[i] == m[j]:
			if i:
				i -= 1
			else:
				p = 1
				break
			if j:
				j -= 1
			else:
				p = 1
				break
		else:
			break
	if p:
		print(abs(len(n) - len(m)))
	else:
		print(i + 1 + j + 1)


a = input()
b = input()
A = a[::-1]
B = b[::-1]
t = min(len(a), len(b))
if a == b:
	print(0)
elif len(a) == 1 and len(b) == 1:
	if a == b:
		print(0)
	else:
		print(len(a) + len(b))
else:
	g = 0
	for k in range(t):
		if A[k] == B[k]:
			pass
		else:
			print(len(a) + len(b) - 2 * k)
			g += 1
			break
	if g == 0:
		print(abs(len(a) - len(b)))


s1 = input()
s2 = input()
i = 1
while i <= min(len(s1), len(s2)) and s1[len(s1) - i] == s2[len(s2) - i]:
	i += 1
print(len(s1) - i + len(s2) - i + 2)


P = 27
Q = 1000000007

def make_hash(s, P, lis, Q):
	for i in range(len(s)):
		lis[i + 1] = (lis[i] * P + ord(s[i]) - 96) % Q
(s1, s2) = (input(), input())
kol = 0
if len(s1) < len(s2):
	kol = len(s2) - len(s1)
	s2 = s2[len(s2) - len(s1):]
elif len(s1) > len(s2):
	kol = len(s1) - len(s2)
	s1 = s1[len(s1) - len(s2):]
p = [1] * (len(s1) + 1)
for i in range(1, len(s1) + 1):
	p[i] = p[i - 1] * P % Q
s1_hash = [0] * (len(s1) + 1)
s2_hash = [0] * (len(s2) + 1)
make_hash(s1, P, s1_hash, Q)
make_hash(s2, P, s2_hash, Q)
length = len(s1)
for i in range(len(s1) + 1):
	if (s1_hash[-1] - s1_hash[i] * p[length - i]) % Q == (s2_hash[-1] - s2_hash[i] * p[length - i]) % Q:
		print(kol + 2 * i)
		break


s = input()
t = input()
if len(s) < len(t):
	a = t
	t = s
	s = a
turns = 0
if len(s) != len(t):
	s_ = ''
	for i in range(len(s) - len(t), len(s)):
		s_ += s[i]
	turns += len(s) - len(t)
	s = s_
cut = 0
for i in range(len(s)):
	if s[i] != t[i]:
		cut = i + 1
turns += cut * 2
print(turns)


s1 = input()[::-1]
s2 = input()[::-1]
i = 0
while True:
	try:
		if s1[i] != s2[i]:
			break
		else:
			i += 1
	except IndexError:
		break
print(len(s1) - i + len(s2) - i)


x = input()
y = input()
same = 0
i = 1
while True and i <= min(len(x), len(y)):
	if x[-i] == y[-i]:
		same += 1
	else:
		break
	i += 1
print(len(x) + len(y) - 2 * same)


(s, t) = (input(), input())
for i in range(1, 90000001):
	try:
		if s[-i] != t[-i]:
			print(len(s) + len(t) + 2 - i * 2)
			break
	except:
		print(abs(len(s) - len(t)))
		break


str1 = input()
str2 = input()
i = 0
while i < min(len(str1), len(str2)):
	if str1[-1 - i] != str2[-1 - i]:
		break
	i += 1
counter = len(str1) + len(str2) - 2 * i
print(counter)


s1 = input()
s2 = input()
count = 0
pos1 = len(s1) - 1
pos2 = len(s2) - 1
for i in range(min(len(s1), len(s2))):
	if s1[pos1] != s2[pos2]:
		break
	else:
		count += 1
		pos1 -= 1
		pos2 -= 1
print(len(s1) - count + len(s2) - count)


def main():
	(s, t) = (input(), input())
	a = len(s)
	b = len(t)
	i = min(a, b)
	j = max(a, b)
	ret = a + b
	if a <= b:
		while i > 0 and s[i - 1] == t[j - 1]:
			i -= 1
			j -= 1
			ret -= 2
	else:
		while i > 0 and t[i - 1] == s[j - 1]:
			i -= 1
			j -= 1
			ret -= 2
	print(ret)
	return 0
main()


import sys
a = [char for char in sys.stdin.readline()]
b = [char for char in sys.stdin.readline()]
i = 0
while len(a) - i - 1 >= 0 and len(b) - i - 1 >= 0 and (a[len(a) - i - 1] == b[len(b) - i - 1]):
	i += 1
print(len(a) - i + (len(b) - i))


s = input()
t = input()
s1 = list(reversed(s))
t1 = list(reversed(t))
c = 0
x = 0
if s == t:
	print(0)
	exit()
z = min(len(t), len(s))
for i in range(z):
	if s1[i] != t1[i]:
		break
	x += 1
print(len(s) + len(t) - x * 2)


strA = input()
strB = input()
del1 = len(strA) - 1
del2 = len(strB) - 1
while strA[del1] == strB[del2] and del1 >= 0 and (del2 >= 0):
	del1 -= 1
	del2 -= 1
print(del1 + del2 + 2)


import math
str1 = input()
str2 = input()
if str1[len(str1) - 1] != str2[len(str2) - 1]:
	print(len(str1) + len(str2))
	exit(0)
i = len(str1) - 1
j = len(str2) - 1
ans = 0
while i >= 0 and j >= 0:
	if str2[j] != str1[i]:
		break
	else:
		ans += 1
	i -= 1
	j -= 1
print(len(str1) + len(str2) - 2 * ans)


s = input()
t = input()
s = '0' + s
t = '1' + t
ss = len(s)
tt = len(t)
foo = 0
l = []
for i in range(1, min(ss, tt) + 1):
	if s[-i] == t[-i]:
		foo += 1
	else:
		print(ss + tt - 2 * foo - 2)
		exit()


s = input()
t = input()
zab = list(zip(s[::-1], t[::-1]))
d = 0
c = 0
for i in range(len(zab)):
	if zab[i][0] == zab[i][1]:
		d += 1
	else:
		break
print(len(s) + len(t) - 2 * d)


(a, b) = [input(), input()]
if len(a) < len(b):
	temp = a
	a = b
	b = temp

def solve():
	diff = len(a) - len(b)
	reverseA = a[::-1]
	resLen = 0
	for (i, c) in enumerate(b[::-1]):
		if c != reverseA[i]:
			resLen = i
			break
		if i == len(b) - 1:
			resLen = len(b)
			break
	print((len(b) - resLen) * 2 + diff)
	return
solve()


def delete_from_left(a, b):
	if a is None and b is None:
		return 0
	if a is None:
		return len(b)
	if b is None:
		return len(a)
	if a[-1] != b[-1]:
		return len(a) + len(b)
	(i, j, w) = (len(a) - 1, len(b) - 1, 0)
	while i >= 0 and j >= 0:
		if a[i] == b[j]:
			w += 1
		elif a[i] != b[j]:
			break
		else:
			pass
		i -= 1
		j -= 1
	return len(a) + len(b) - 2 * w
(a, b) = (str(input()), str(input()))
print(delete_from_left(a, b))


s1 = str(input())
s2 = str(input())
ans = 400000
flag = 0
j = 0
l = len(s1)
m = len(s2)
i = 1
while flag == 0 and i <= min(len(s1), len(s2)):
	if s1[l - i] != s2[m - i]:
		flag = 1
		ans = l - i + 1 + m - i + 1
		break
	i += 1
	j += 1
if flag == 0:
	print(l + m - 2 * j)
else:
	print(ans)


s1 = input()
s2 = input()
s1 = s1[::-1]
s2 = s2[::-1]
count = 0
for i in range(min(len(s1), len(s2))):
	if s1[i] == s2[i]:
		count += 1
	else:
		break
ans = len(s1) - count + (len(s2) - count)
print(ans)


first = input()
second = input()
first_len = len(first)
second_len = len(second)
smallest = first_len if first_len < second_len else second_len
characters_remain = 0
for i in range(-1, -(smallest + 1), -1):
	if first[i] == second[i]:
		characters_remain += 2
		continue
	break
print(first_len + second_len - characters_remain)


s = input()
t = input()
n = len(s)
m = len(t)
inner = 0
i = len(s) - 1
j = len(t) - 1
while i >= 0 and j >= 0:
	if s[i] == t[j]:
		inner += 1
		i -= 1
		j -= 1
	else:
		break
print(n + m - 2 * inner)


a = input()
b = input()
l = min(len(a), len(b))
m = 0
for i in range(1, l + 1):
	if a[-i] == b[-i]:
		m = i
	else:
		break
print(len(a) - m + len(b) - m)


s = input()
t = input()
if len(s) > len(t):
	big = s
	small = t
else:
	big = t
	small = s
max_size = len(big)
min_size = len(small)
count = max_size + min_size
for i in range(min_size):
	if big[max_size - i - 1] == small[min_size - 1 - i]:
		count -= 2
	else:
		break
print(count)


s1 = input()
s2 = input()
i = len(s1) - 1
j = len(s2) - 1
flag = 0
for k in range(min(len(s1), len(s2))):
	if s1[i] != s2[j]:
		flag = 1
		break
	i = i - 1
	j = j - 1
if flag == 1:
	print(i + 1 + j + 1)
else:
	print(max(i, j) + 1)


a = input()[::-1]
b = input()[::-1]
n = min(len(a), len(b))
count = 0
for i in range(n):
	if a[i] == b[i]:
		count += 1
	else:
		break
print(len(a) + len(b) - 2 * count)


while True:
	try:
		s = input()
		t = input()
		same = 0
		for (a, b) in zip(s[::-1], t[::-1]):
			if a != b:
				break
			same += 1
		print(len(s) - same + len(t) - same)
	except:
		break


s1 = input()
s2 = input()
a = len(s1) - 1
b = len(s2) - 1
while a >= 0 and b >= 0 and (s1[a] == s2[b]):
	a -= 1
	b -= 1
print(a + b + 2)


def sol(s1, s2):
	if s1 == s2:
		print(0)
	else:
		i = len(s1) - 1
		j = len(s2) - 1
		while i > -1 and j > -1 and (s1[i] == s2[j]):
			i -= 1
			j -= 1
		print(i + 1 + j + 1)

def main():
	s1 = input()
	s2 = input()
	sol(s1, s2)
main()


s1 = input()
s2 = input()
r = len(s1) + len(s2)
for (i, j) in zip(s1[::-1], s2[::-1]):
	if i != j:
		break
	else:
		r -= 2
print(r)


first = input()
second = input()

def solve():
	if first[-1] != second[-1]:
		return len(first) + len(second)
	i = len(first) - 1
	j = len(second) - 1
	while i > -1 and j > -1 and (first[i] == second[j]):
		i -= 1
		j -= 1
	return i + j + 2
print(solve())


import sys
input = sys.stdin.readline
s = input()
t = input()
ks = len(s) - 1
kt = len(t) - 1
cur = 0
while s[ks] == t[kt]:
	cur += 1
	ks -= 1
	kt -= 1
	if ks < 0 or kt < 0:
		break
result = len(s) - 2 * cur + len(t)
print(result)


def matchStrings(s, t):
	indFromBack = 0
	sLast = len(s) - 1
	tLast = len(t) - 1
	cap = min(sLast, tLast)
	while cap - indFromBack >= 0 and s[sLast - indFromBack] == t[tLast - indFromBack]:
		indFromBack += 1
	print(len(s) + len(t) - 2 * indFromBack)

def main():
	strS = input()
	strT = input()
	matchStrings(strS, strT)
main()


qq = input()
qq1 = input()
if len(qq) < len(qq1):
	x = qq1
	t = qq
else:
	x = qq
	t = qq1
counter = 0
for num in range(1, len(t) + 1):
	if t[-num] == x[-num]:
		counter += 1
	else:
		break
if counter == 0:
	print(len(t) + len(x))
else:
	print(len(t) - counter + (len(x) - counter))


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_int = lambda : int(sys.stdin.readline())
s = get_string()[::-1]
n1 = len(s)
t = get_string()[::-1]
n2 = len(t)
i = j = 0
while i < n1 and j < n2 and (s[i] == t[j]):
	i += 1
	j += 1
print(n1 - i + n2 - j)


s1 = input()[::-1]
s2 = input()[::-1]
n = 0
for (c1, c2) in zip(s1, s2):
	if c1 != c2:
		break
	n += 1
print(len(s1) + len(s2) - 2 * n)


s = list(input())
t = list(input())
i = 0
ls = len(s)
lt = len(t)
num = min(len(s), len(t))
for i in range(1, num + 1):
	if s[ls - i] == t[lt - i]:
		del [s[ls - i]]
		del [t[lt - i]]
	else:
		break
print(len(s) + len(t))


a = input()[::-1]
b = input()[::-1]
(al, bl) = (len(a), len(b))
for i in range(min(al, bl)):
	if a[i] != b[i]:
		print(al + bl - 2 * i)
		exit(0)
print(abs(al - bl))


t = input()
s = input()
i = 0
maximum = min(len(s), len(t))
while s[len(s) - 1 - i] == t[len(t) - 1 - i]:
	if i < maximum:
		i += 1
	else:
		break
print(len(t) - i + (len(s) - i))


s1 = input().strip()
ls1 = len(s1)
s2 = input().strip()
ls2 = len(s2)
mlen = min(ls1, ls2)
pos = 1
while pos <= mlen and s1[-pos] == s2[-pos]:
	pos += 1
c = ls1 - (pos - 1) + ls2 - (pos - 1)
print(c)


import sys
import io
stream_enable = 0
inpstream = '\ncodeforces\nyes\n'
if stream_enable:
	sys.stdin = io.StringIO(inpstream)
	input()

def inpmap():
	return list(map(int, input().split()))
a = input()
b = input()
k = len(a) + len(b)
for i in range(min(len(a), len(b))):
	if a[-i - 1] == b[-i - 1]:
		k -= 2
	else:
		break
print(k)


def calc(s, t):
	for i in range(len(s)):
		if s[-i - 1] != t[-i - 1]:
			start = len(s) - i
			break
	else:
		start = 0
	return 2 * start + len(t) - len(s)

def get_ints():
	return [int(n) for n in input().split()]

def get_floats():
	return [float(n) for n in input().split()]
(s, t) = (input(), input())
res = calc(s, t) if len(s) <= len(t) else calc(t, s)
print(res)


def left_delete(s1, s2):
	t = min(len(s1), len(s2))
	count = 0
	for i in range(0, t):
		if s1[len(s1) - i - 1] == s2[len(s2) - i - 1]:
			count += 1
		else:
			break
	return len(s1) + len(s2) - 2 * count
t1 = input()
t2 = input()
print(left_delete(t1, t2))


a = input()
b = input()
c = len(a)
d = len(b)
count = 0
f = 0
if c <= d:
	j = 1
	for i in range(c - 1, -1, -1):
		if a[i] != b[d - j]:
			j = -1
			break
		else:
			j += 1
			f += 1
	count += c - f + (d - f)
else:
	j = 1
	for i in range(d - 1, -1, -1):
		if b[i] != a[c - j]:
			j = -1
			break
		else:
			j += 1
			f += 1
	count += c - f + (d - f)
print(count)


def part_a():
	a = str(input())
	b = str(input())
	min_moves = len(a) + len(b)
	a_end = len(a) - 1
	b_end = len(b) - 1
	found = False
	while a_end > -1 and b_end > -1:
		if a[a_end] == b[b_end]:
			found = True
			min_moves = len(a) - (len(a) - a_end) + len(b) - (len(b) - b_end)
			a_end -= 1
			b_end -= 1
		elif not found:
			min_moves = len(a) + len(b)
			break
		else:
			break
	print(min_moves)
part_a()


string1 = input()[::-1]
string2 = input()[::-1]
res = 0
for i in range(min(len(string1), len(string2))):
	if string1[i] == string2[i]:
		res += 1
	else:
		break
print(len(string1) - res + len(string2) - res)


s = input()
t = input()
i = 1
while i < min(len(s), len(t)) + 1 and s[len(s) - i] == t[len(t) - i]:
	i += 1
print(len(s) + len(t) - 2 * (i - 1))


s1 = input()
s1 = s1[::-1]
s2 = input()
s2 = s2[::-1]
if s1[0] != s2[0]:
	print(len(s1) + len(s2))
else:
	i = 0
	while i < len(s1) and i < len(s2) and (s1[i] == s2[i]):
		i += 1
	print(len(s1) - i + len(s2) - i)


a = input()
b = input()
cntr = 0
curr = min(len(a), len(b)) - 1
for i in range(1, min(len(a), len(b)) + 1, 1):
	if a[-i] == b[-i]:
		cntr += 1
	else:
		break
print(len(a) - cntr + len(b) - cntr)


a = input()
b = input()
t = min(len(a), len(b))
flag = 0
for i in range(1, t + 1):
	if a[-i] == b[-i]:
		continue
	else:
		flag = 1
		break
if flag == 0:
	print(len(a) - i + len(b) - i)
else:
	print(len(a) - (i - 1) + len(b) - (i - 1))


import collections
s1 = input()
s2 = input()
if s1 == s2:
	print(0)
else:
	i = len(s1) - 1
	j = len(s2) - 1
	c = 0
	while s1[i] == s2[j]:
		c += 1
		i -= 1
		j -= 1
		if i == -1 or j == -1:
			break
	a = len(s1) + len(s2) - 2 * c
	print(a)


a = str(input())
b = str(input())
p = 0
k = 0
t = 0
g = 0
d = 0
while p == 0 and t == 0:
	if a[len(a) - k - 1] != b[len(b) - k - 1]:
		p = 1
	else:
		g = g + 1
	k = k + 1
	if k == len(b):
		t = 1
	elif k == len(a):
		t = 1
print(len(a) - g + (len(b) - g))


from sys import stdin, stdout
s = stdin.readline()
t = stdin.readline()
count = 0
l = min(len(s), len(t))
s = s[::-1]
t = t[::-1]
for i in range(l):
	if s[i] == t[i]:
		count += 1
	else:
		break
print(len(s) + len(t) - 2 * count)


(k, l) = (input(), input())
(k1, l1, c) = (len(k), len(l), 0)
while k1 > 0 and l1 > 0 and (k[k1 - 1] == l[l1 - 1]):
	k1 -= 1
	l1 -= 1
print(k1 + l1)


k1 = input()
k2 = input()
t1 = len(k1)
t2 = len(k2)
mini = min(t1, t2)
count = 0
k1 = k1[::-1]
k2 = k2[::-1]
for i in range(mini):
	if k1[i] == k2[i]:
		count += 1
	else:
		break
print(t1 - count + t2 - count)


import sys
input = sys.stdin.readline
ins = lambda : input().rstrip()
ini = lambda : int(input().rstrip())
inm = lambda : map(int, input().rstrip().split())
inl = lambda : list(map(int, input().split()))
out = lambda x, s='\n': print(s.join(map(str, x)))
s = ins()
t = ins()
ans = 0
for i in range(1, min(len(s), len(t)) + 1):
	if s[-i] != t[-i]:
		break
	ans += 2
print(len(s) + len(t) - ans)


s = input()
t = input()
if len(s) > len(t):
	p = s[len(s) - len(t):]
	j = len(t) - 1
	r = len(s) + len(t)
	while j >= 0:
		if p[j] == t[j]:
			r += -2
		else:
			break
		j += -1
else:
	p = t[len(t) - len(s):]
	j = len(s) - 1
	r = len(s) + len(t)
	while j >= 0:
		if p[j] == s[j]:
			r += -2
		else:
			break
		j += -1
print(r)


S = list(str(input()))
T = list(str(input()))
lS = len(S)
lT = len(T)
S = S[::-1]
T = T[::-1]
if lS > lT:
	T += '0' * (lS - lT)
elif lT > lS:
	S += '0' * (lT - lS)
P = lS + lT
for i in range(0, len(S)):
	if S[i] == T[i]:
		P -= 2
	else:
		print(P)
		exit()
print(P)


n = list(input())
k = list(input())
i = -1
c = 0
reversed(n)
reversed(k)
try:
	while n[i] == k[i]:
		i -= 1
		c += 2
except IndexError:
	assert True
print(len(n) + len(k) - c)


s = input()
t = input()
s = s[::-1]
t = t[::-1]
i = -1
j = -1
while s[i + 1] == t[j + 1]:
	i = i + 1
	j = j + 1
	if i == len(s) - 1 or j == len(t) - 1:
		break
if i == -1:
	print(len(s) + len(t))
else:
	print(len(s) + len(t) - (i + j + 2))


s = input()
t = input()
m = len(s)
n = len(t)
if len(s) == 0 or len(t) == 0:
	print(max(len(s), len(t)))
elif s[-1] != t[-1]:
	print(len(s) + len(t))
elif len(s) >= len(t):
	p = len(s) - len(t)
	s = s[p:]
	i = len(s) - 1
	c = 0
	while i >= 0 and s[i] == t[i]:
		c += 1
		i = i - 1
	print(m + n - 2 * c)
else:
	p = len(t) - len(s)
	t = t[p:]
	i = len(s) - 1
	c = 0
	while i >= 0 and s[i] == t[i]:
		c += 1
		i = i - 1
	print(m + n - 2 * c)


a = input()
b = input()
c = len(a) - 1
d = len(b) - 1
while c >= 0 and d >= 0 and (a[c] == b[d]):
	c = c - 1
	d = d - 1
print(c + d + 2)


(s1, s2) = (input(), input())
(n1, n2) = (len(s1), len(s2))
if n1 > n2:
	s2 = '*' * (n1 - n2) + s2
elif n2 > n1:
	s1 = '*' * (n2 - n1) + s1
ans = 0
for i in range(max(n1, n2) - 1, max(n1, n2) - min(n1, n2) - 1, -1):
	if s1[i] == s2[i]:
		ans += 1
	else:
		break
print(n1 + n2 - 2 * ans)


def main():
	str1 = input()[::-1]
	str2 = input()[::-1]
	cnt = 0
	for i in range(min(len(str1), len(str2))):
		if str1[i] == str2[i]:
			cnt += 1
		else:
			break
	print(len(str1) + len(str2) - 2 * cnt)
main()


a = input()[::-1]
b = input()[::-1]
s = max(len(a), len(b))
t = min(len(a), len(b))
for i in range(t):
	if a[i] != b[i]:
		print(len(a) + len(b) - 2 * i)
		exit(0)
print(s - t)


s = input()
t = input()
s = s[::-1]
t = t[::-1]
x = 0
minlen = min([len(s), len(t)])
while x < minlen:
	if s[x] == t[x]:
		x += 1
	else:
		break
result = len(s) + len(t) - x * 2
print(result)


def go():
	a = list(reversed([i for i in input()]))
	b = list(reversed([i for i in input()]))
	na = len(a)
	nb = len(b)
	total = 0
	i = 0
	j = 0
	while i < na and j < nb and (a[i] == b[j]):
		i += 1
		j += 1
	return na - i + (nb - j)
print(go())


count = 0
w1 = list(input())
w2 = list(input())
(l1, l2) = (len(w1), len(w2))
try:
	while w1.pop() == w2.pop():
		count += 1
except IndexError:
	pass
print(l1 + l2 - 2 * count)


s = input()
t = input()
s1 = s[::-1]
t1 = t[::-1]
m = min(len(s), len(t))
ans = 0
for i in range(m):
	if s1[i] == t1[i]:
		ans += 1
	else:
		break
if ans == 0:
	print(len(s) + len(t))
else:
	print(len(s) + len(t) - 2 * ans)


(s, t) = (input(), input())
f = 0
if len(t) >= len(s):
	l = len(s) - 1
	while f <= l:
		m = (f + l) // 2
		if s[len(s) - m:] != t[len(t) - m:]:
			l = m - 1
		else:
			f = m + 1
else:
	l = len(t) - 1
	while f <= l:
		m = (f + l) // 2
		if s[len(s) - m:] != t[len(t) - m:]:
			l = m - 1
		else:
			f = m + 1
while s[len(s) - m:] != t[len(t) - m:] and m >= 0 and (m >= 0):
	m -= 1
while s[len(s) - m:] == t[len(t) - m:] and m <= len(s) and (m <= len(t)):
	m += 1
print(len(s) + len(t) - 2 * m + 2)


s = input()
s1 = input()
len1 = len(s) - 1
len2 = len(s1) - 1
while True and len1 >= 0 and (len2 >= 0):
	if s[len1] == s1[len2]:
		len1 -= 1
		len2 -= 1
	else:
		break
print(len1 + len2 + 2)


a = list(input())
b = list(input())
x = min(len(a), len(b))
y = max(len(a), len(b))
c = y - x
for i in range(x):
	if a[-i - 1] != b[-i - 1]:
		c = x + y - 2 * i
		break
print(c)


s = input()
t = input()
q = 0
i1 = len(t) - 1
i2 = len(s) - 1
while i1 >= 0 and i2 >= 0:
	if s[i2] == t[i1]:
		q += 1
		i1 -= 1
		i2 -= 1
	else:
		break
su1 = len(s) - q
su2 = len(t) - q
print(su1 + su2)


s = input()
t = input()
i = len(s)
j = len(t)
var1 = i
var2 = j
count = 0
while s[var1 - 1] == t[var2 - 1]:
	count = count + 1
	var1 = var1 - 1
	var2 = var2 - 1
	if var1 == 0 or var2 == 0:
		break
print(i + j - 2 * count)


str1 = input()
str2 = input()
if len(str1) < len(str2):
	min = len(str1)
else:
	min = len(str2)
str1 = str1[::-1]
str2 = str2[::-1]
same = 0
for i in range(min):
	if str1[i] == str2[i]:
		same += 1
	else:
		break
print(len(str1) + len(str2) - 2 * same)


s = str(input())
t = str(input())
w = 0
while True:
	i = len(s) - w - 1
	j = len(t) - w - 1
	if i >= 0 and j >= 0 and (s[i] == t[j]):
		w += 1
	else:
		break
print(len(s) + len(t) - 2 * w)


s = list(input())
t = list(input())
length = min(len(s), len(t))
c = length
for i in range(length):
	if s[len(s) - i - 1] != t[len(t) - i - 1]:
		c = i
		break
print(len(s) - c + len(t) - c)


a = list(input())
b = list(input())
c = len(a)
d = len(b)
l = c + d
if c >= d:
	shorter = b
	longer = a
else:
	shorter = a
	longer = b
for k in range(1, len(shorter) + 1):
	if shorter[-k] == longer[-k]:
		l -= 2
	else:
		break
print(l)


s = input()
t = input()
ls = len(s)
lt = len(t)
maxl = max(ls, lt)
minl = min(ls, lt)

def calculate_moves():
	if s[-minl:] == t[-minl:]:
		return maxl - minl
	for i in range(1, minl + 1):
		if s[-i] != t[-i]:
			return ls - (i - 1) + (lt - (i - 1))
	return maxl - minl
print(calculate_moves())


st1 = input()
st2 = input()
a = 0
k = 0
l1 = len(st1)
l2 = len(st2)
while True:
	if l1 - k - 1 >= 0 and l2 - k - 1 >= 0 and (st1[l1 - k - 1] == st2[l2 - k - 1]):
		a += 1
	else:
		break
	k += 1
ans = len(st1) - a + len(st2) - a
print(str(ans))


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	s = S()
	t = S()
	l = min(len(s), len(t))
	k = 0
	for i in range(l):
		if s[-1 - i] != t[-1 - i]:
			break
		k += 1
	return len(s) + len(t) - k * 2
print(main())


x = input()
y = input()
a = len(x)
b = len(y)
c = 0
if a < b:
	(x, y) = (y, x)
	(a, b) = (b, a)
x = x[a - b:]
for i in range(len(x)):
	if x[b - 1 - i] == y[b - 1 - i]:
		c += 1
	else:
		break
print(a + b - c * 2)


s = input()
t = input()
a = []
b = []
for i in s:
	a.append(i)
a.reverse()
for i in t:
	b.append(i)
b.reverse()
ans = 0
flag = 0
j = 0
for i in range(min(len(a), len(b))):
	if a[i] == b[i]:
		j += 1
	else:
		break
if j == 0:
	ans = len(a) + len(b)
else:
	ans = len(a) - j + len(b) - j
print(ans)


s1 = input()
s2 = input()
L1 = list(s1)
L2 = list(s2)
l1 = L1[::-1]
l2 = L2[::-1]
(c, c1) = (0, 0)
if len(l1) <= len(l2):
	for i in range(len(l1)):
		if l1[i] == l2[i]:
			c += 1
		else:
			break
		c1 += 1
	if c1 == 0:
		print(len(l1) + len(l2))
	else:
		print(len(l1) - c + len(l2) - c)
else:
	for i in range(len(l2)):
		if l1[i] == l2[i]:
			c += 1
		else:
			break
		c1 += 1
	if c1 == 0:
		print(len(l1) + len(l2))
	else:
		print(len(l1) - c + len(l2) - c)


s = input()
t = input()
k = 0
a = len(s)
b = len(t)
for i in range(1, min(a, b) + 1):
	if s[-i] == t[-i]:
		k = k + 1
	else:
		break
print(a + b - 2 * k)


s1 = input()
s2 = input()
minn = min(len(s1), len(s2))
eq = 0
k = -1
while k >= -minn:
	if s1[k] == s2[k]:
		eq += 1
	else:
		break
	k = k - 1
print(len(s1) + len(s2) - 2 * eq)


s1 = list(input()[::-1])
s2 = list(input()[::-1])
n = len(s1)
m = len(s2)
ans = 0
for i in range(min(m, n)):
	if s1[i] == s2[i]:
		ans += 1
	else:
		break
print(n + m - 2 * ans)


string1 = input().strip()
string2 = input().strip()
count = 0
for i in range(-1, -1 * min(len(string1), len(string2)) - 1, -1):
	if string1[i] == string2[i]:
		count += 1
	else:
		break
print(len(string1) - count + len(string2) - count)


(s, t) = (input(), input())
(i, j, z) = (len(s) - 1, len(t) - 1, 0)
while True:
	if i - z < 0 or j - z < 0:
		break
	if s[i - z] != t[j - z]:
		break
	z += 1
print(len(s) + len(t) - 2 * z)


s = input()
t = input()
s = s[::-1]
t = t[::-1]
count = 0
for i in range(min(len(s), len(t))):
	if s[i] == t[i]:
		count += 1
	else:
		break
ans = len(s) - count + (len(t) - count)
print(ans)


def sol(s1, s2):
	m = len(s1)
	n = len(s2)
	i = m - 1
	j = n - 1
	while i > -1 and j > -1 and (s1[i] == s2[j]):
		i -= 1
		j -= 1
	print(i + 1 + j + 1)

def main():
	s1 = input()
	s2 = input()
	sol(s1, s2)
main()


(a, b) = (input(), input())
x = True
if a > b:
	g = len(b)
	d = 1
elif a == b:
	if a == b:
		x = False
		print(0)
	else:
		x = False
		print(len(a) + len(b))
else:
	g = len(a)
	d = 2
if x:
	i = 1
	while i != g + 1:
		try:
			if a[-i] == b[-i]:
				i += 1
			else:
				i -= 1
				if d == 2:
					print(g + len(b) - i * 2)
					break
				else:
					print(g + len(a) - i * 2)
					break
		except Exception:
			i -= 1
			if d == 2:
				print(g + len(b) - i * 2)
				break
			else:
				print(g + len(a) - i * 2)
				break
	else:
		i -= 1
		if d == 1:
			print(len(a) - i)
		else:
			print(len(b) - i)


string_small = input()
string_big = input()
if len(string_small) > len(string_big):
	(string_small, string_big) = (string_big, string_small)
count = 0
for i in range(-1, -len(string_small) - 1, -1):
	if string_small[i] != string_big[i]:
		break
	else:
		count += 1
moves = len(string_small) - count + (len(string_big) - count)
print(moves)


s = input()
t = input()
a = len(s)
b = len(t)
while a > 0 and b > 0:
	if s[a - 1] != t[b - 1]:
		break
	a -= 1
	b -= 1
l1 = len(s[0:a])
l2 = len(t[0:b])
print(l1 + l2)


list1 = list(input())
list2 = list(input())
p = len(list1)
q = len(list2)
pp = p
qq = q
m = min(p, q)
ctr = 0
while p > 0 and q > 0:
	if list1[p - 1] == list2[q - 1]:
		ctr = ctr + 1
		p = p - 1
		q = q - 1
	else:
		break
print(pp - ctr + qq - ctr)


a = input()
b = input()
index = 0
for i in range(1, 1 + min(len(a), len(b))):
	if a[-i] != b[-i]:
		break
	index += 1
if a[-1] != b[-1]:
	index = 0
print(len(a) + len(b) - 2 * index)


(a, b) = (input(), input())
(n, m, i) = (len(a), len(b), 1)
while i <= min(n, m) and a[-i] == b[-i]:
	i += 1
print(n + m - 2 * i + 2)


s1 = input()[::-1]
s2 = input()[::-1]
n = len(s1)
f = len(s2)
if s2 == s1[:f]:
	print(n - f)
	exit(0)
if s1 == s2[:n]:
	print(f - n)
	exit(0)
for i in range(n):
	if s1[i] != s2[i]:
		k = i
		break
print(n + f - k * 2)


import sys
s = input()
t = input()
m = len(s)
n = len(t)
c = 0
c1 = 0
if m > n:
	s1 = s[-n:]
	c += m - n
	if s1 == t:
		print(c)
		sys.exit(0)
	for i in range(n - 1, -1, -1):
		if s1[i] != t[i]:
			break
		c1 += 1
	print(c + 2 * (n - c1))
	sys.exit(0)
else:
	t1 = t[-m:]
	c += n - m
	if t1 == s:
		print(c)
		sys.exit(0)
	for i in range(m - 1, -1, -1):
		if t1[i] != s[i]:
			break
		c1 += 1
	print(c + 2 * (m - c1))
	sys.exit(0)


s1 = input().strip()
s2 = input().strip()
s1 = s1[::-1]
s2 = s2[::-1]
i = 0
ans = ''
while i < min(len(s1), len(s2)):
	if s1[i] != s2[i]:
		ans = len(s1) + len(s2) - 2 * i
		break
	i += 1
print(ans if len(str(ans)) else len(s1) + len(s2) - 2 * i)


w1 = str(input())
w2 = str(input())
a = [len(w1), len(w2)]
n = 0
for i in range(-1, min(a) * -1 - 1, -1):
	if w1[i] != w2[i]:
		break
	else:
		n += 1
print(a[1] - n + a[0] - n)


def mi():
	return map(int, input().split())
a = list(input())[::-1]
b = list(input())[::-1]
s = -1
for i in range(min(len(a), len(b))):
	if a[i] != b[i]:
		s = i
		break
if s == -1:
	print(abs(len(a) - len(b)))
else:
	print(len(a) + len(b) - 2 * s)


s1 = input().strip()[::-1]
s2 = input().strip()[::-1]
k = 0
while k < len(s1) and k < len(s2) and (s1[k] == s2[k]):
	k += 1
print(len(s1) + len(s2) - 2 * k)


st1 = input()
st2 = input()
l1 = len(st1)
l2 = len(st2)
min = min(l1, l2)
i = 1
count = 0
while i <= min and st1[l1 - i] == st2[l2 - i]:
	count = count + 1
	i = i + 1
total = l1 - count + (l2 - count)
print(total)


s = [i for i in input()]
t = [i for i in input()]
c = max(len(s), len(t))
d = min(len(s), len(t))
ans = 0
s_n = s[::-1]
t_n = t[::-1]
if d == 1 and s_n[0] == t_n[0]:
	ans = c + d - 2
else:
	for i in range(0, d):
		if s_n[i] != t_n[i]:
			ans = c + d - i * 2
			break
		if d - 1 == i and c == d:
			ans = 0
		if d - 1 == i and c != d:
			ans = c + d - (i + 1) * 2
print(ans)


a = input()
b = input()
m = len(a)
n = len(b)
ans = m + n
if len(a) > len(b):
	b = ' ' * (len(a) - len(b)) + b
elif len(a) < len(b):
	a = ' ' * (len(b) - len(a)) + a
for i in range(len(a) - 1, -1, -1):
	if a[i] == ' ' or b[i] == ' ':
		break
	if a[i] != b[i]:
		break
	else:
		ans -= 2
print(ans)


from sys import stdin
trim = lambda s: s[:-1] if s[-1] == '\n' else s
s = trim(stdin.readline())
t = trim(stdin.readline())
i = 0
while (i < len(s) and i < len(t)) and s[-1 - i] == t[-1 - i]:
	i += 1
print(len(s) + len(t) - 2 * i)


a = input()
b = input()
a = a[::-1]
b = b[::-1]
lena = len(a)
lenb = len(b)
i = 0
ans = 0
while 1:
	if lena != 0 and lenb != 0 and (a[i] == b[i]):
		lena -= 1
		lenb -= 1
		i += 1
	else:
		break
ans = lena + lenb
print(ans)


s = str(input())
n = len(s)
t = str(input())
m = len(t)
k = 0
while n - k - 1 >= 0 and m - k - 1 >= 0 and (s[n - k - 1] == t[m - k - 1]):
	k += 1
print(n + m - 2 * k)


def main():
	s1 = input()
	s2 = input()
	i = -1
	while abs(i) <= len(s1) and abs(i) <= len(s2) and (s1[i] == s2[i]):
		i -= 1
	size1 = len(s1)
	size2 = len(s2)
	ans = size1 + i + size2 + i + 2
	print(ans)
main()


(s, t) = (input(), input())
(i, j) = (len(s) - 1, len(t) - 1)
x = 0
while i != -1 and j != -1:
	if s[i] != t[j]:
		break
	x += 1
	i -= 1
	j -= 1
print(len(s) + len(t) - 2 * x)


import sys
from collections import Counter

def main():
	s = input()
	t = input()
	(n, m) = (len(s), len(t))
	common = 0
	for i in range(min(n, m)):
		if s[n - i - 1] != t[m - i - 1]:
			break
		common += 1
	print(n + m - 2 * common)
main()


import sys
from bisect import insort, bisect_right
data = sys.stdin.readlines()
lis = []
for line in data:
	lis.append(line)

def dist(i, j):
	return abs(i - j)
wrd1 = list(lis[0])[::-1]
wrd2 = list(lis[1])[::-1]
if wrd1[0] == '\n':
	wrd1 = wrd1[1:]
if wrd2[0] == '\n':
	wrd2 = wrd2[1:]
l = min(len(wrd1), len(wrd2))
m = max(len(wrd1), len(wrd2))
ind = 0
for i in range(l):
	if wrd1[i] != wrd2[i]:
		break
	ind = i + 1
print(l + m - 2 * ind)


s = str(input())
t = str(input())
m = len(s)
n = len(t)
o = min(m, n)
flag = True
c = 0
for i in range(o):
	if flag and s[-i - 1] == t[-i - 1]:
		c += 1
	else:
		flag = False
print(m + n - 2 * c)


s = input()
t = input()
k = 0
if len(s) > len(t):
	k = len(s) - len(t)
	s = s[len(s) - len(t):len(s)]
elif len(t) > len(s):
	k = len(t) - len(s)
	t = t[len(t) - len(s):len(t)]
for i in range(len(s) - 1, -1, -1):
	if s[i] != t[i]:
		print(k + (i + 1) * 2)
		exit(0)
print(k)


import sys
from collections import *
from math import *
import re

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	c = 0
	for i in range(2, n):
		if prime[i]:
			c += 1
	return c

def iseven(n):
	return [False, True][0 if n % 2 else 1]

def inp_arr():
	return list(map(int, input().split()))

def inp():
	return map(int, input().split())

def lcm(a, b):
	return a * b / gcd(a, b)
max_int = sys.maxsize
mod = 10 ** 9 + 7
c = 0
(s, t) = (input(), input())
for (i, j) in zip(s[::-1], t[::-1]):
	if i == j:
		c += 1
	else:
		break
print(len(s) + len(t) - 2 * c)


import math
from collections import defaultdict
getInputList = lambda : list(input().split())
getInputIntList = lambda : list(map(int, input().split()))
a = list(input())
b = list(input())
n = len(a) - 1
m = len(b) - 1
for i in range(min(n, m) + 1):
	if a[n] != b[m]:
		break
	m -= 1
	n -= 1
print(n + m + 2)


s = input()
t = input()
ls = len(s)
lt = len(t)
inds = ls - 1
indt = lt - 1
while inds >= 0 and indt >= 0 and (s[inds] == t[indt]):
	inds -= 1
	indt -= 1
print(inds + indt + 2)


s1 = input()
t1 = input()
s = s1[::-1]
t = t1[::-1]
result = 0
for i in range(min(len(s), len(t))):
	if s[i] != t[i]:
		result = min(len(s), len(t)) * 2 - i * 2
		break
result += max(len(s), len(t)) - min(len(s), len(t))
print(result)


s1 = input()
s2 = input()
x = max(len(s1), len(s2)) - min(len(s1), len(s2))
if len(s1) < len(s2):
	s2 = s2[x:]
if len(s2) < len(s1):
	s1 = s1[x:]
dif = -1
for i in range(len(s1) - 1, -1, -1):
	if s1[i] != s2[i]:
		dif = i
		break
x += len(s1) + len(s2) - (len(s1) - 1 - dif) * 2
print(x)


s = str(input())
t = str(input())
cou = 0
for i in range(-1, -max(len(s), len(t)) - 1, -1):
	try:
		if s[i] == t[i]:
			cou += 1
		else:
			break
	except:
		break
ans = len(s) - cou + len(t) - cou
print(ans)


str1 = input()
str2 = input()
len1 = len(str1)
len2 = len(str2)
mx = len1 + len2
i = len1 - 1
j = len2 - 1
while i >= 0 and j >= 0:
	if str1[i] == str2[j]:
		mx -= 2
	else:
		break
	i -= 1
	j -= 1
print(mx)


def calc(a, d):
	i = len(a) - 1
	j = len(d) - 1
	val = 0
	while i >= 0 and j >= 0 and (a[i] == d[j]):
		i -= 1
		j -= 1
		val += 1
	print(len(a) - val + len(d) - val)
a = input()
d = input()
calc(a, d)


s = list(str(input()))
t = list(str(input()))
s.reverse()
t.reverse()
n = min(len(s), len(t))
for i in range(n):
	if s[i] != t[i]:
		break
else:
	i = n
ans = len(s) - i + len(t) - i
print(ans)


import sys
s = input()
t = input()
c = 0
i = -1
l = len(s)
l1 = len(t)
if s == t:
	print('0')
	sys.exit()
if l == 0 or l1 == 0:
	print(l + l1)
	sys.exit()
if l == 1 or l1 == 1:
	if s[-1] == t[-1]:
		c += 1
else:
	while -i <= min(l, l1) and s[i] == t[i]:
		c += 1
		i -= 1
print(l + l1 - 2 * c)


a = input()
b = input()
i = 1
while len(a) - i >= 0 and len(b) - i >= 0 and (a[len(a) - i] == b[len(b) - i]):
	i += 1
i -= 1
print(len(a) - i + len(b) - i)


str1 = input()
str2 = input()
l1 = len(str1)
l2 = len(str2)
i = l1
j = l2
s = 0
for (i, j) in zip(range(l1 - 1, -1, -1), range(l2 - 1, -1, -1)):
	if str1[i] != str2[j]:
		s = 1
		break
else:
	print(max(l1 - l2, l2 - l1))
if s:
	print(j + i + 2)


import os
import sys
from io import BytesIO, IOBase
from collections import Counter
from collections import deque
import heapq
import math
import statistics

def sin():
	return input()

def ain():
	return list(map(int, sin().split()))

def sain():
	return input().split()

def iin():
	return int(sin())
MAX = float('inf')
MIN = float('-inf')

def main():
	a = sin()
	b = sin()
	i = 0
	j = 0
	flag = 0
	n = len(a)
	m = len(b)
	x = n
	y = m
	flag = 1
	while flag and n > 0 and (m > 0):
		if a[n - 1] != b[m - 1]:
			flag = 0
		else:
			n -= 1
			m -= 1
	print(n + m)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


s = input()
s2 = input()
l1 = len(s)
l2 = len(s2)
t = 0
for i in range(1, min(l1, l2) + 1):
	if s[l1 - i] == s2[l2 - i]:
		t = t + 1
	else:
		break
print(l1 + l2 - 2 * t)


n = list(input())
m = list(input())
(k, l, s) = (len(n), len(m), 0)
if n[len(n) - 1] != m[len(m) - 1]:
	print(len(n) + len(m))
	exit()
while n[k - 1] == m[l - 1]:
	k -= 1
	l -= 1
	s = k + l
	if k == 0 or l == 0:
		break
print(s)


String = input()
String2 = input()
f = len(String)
g = len(String2)
s = 0
for i in range(1, min(f, g) + 1):
	if String[f - i] == String2[g - i]:
		s += 1
	else:
		break
print(f + g - 2 * s)


s1 = list(input())
s2 = list(input())
s1.reverse()
s2.reverse()
n = min(len(s1), len(s2))
c = 0
i = 0
while i < n and s1[i] == s2[i]:
	c += 1
	i += 1
print(len(s1) + len(s2) - 2 * c)


a = input()
b = input()
x = len(a)
y = len(b)
z = 0
for i in range(x - 1, -1, -1):
	if y - 1 - z >= 0:
		if a[i] == b[y - 1 - z]:
			z = z + 1
		else:
			break
s = x - z
j = y - z
t = s + j
print(t)


import sys
input = sys.stdin.readline

def main():
	a = instr()
	b = instr()
	if a == b:
		print(0)
	else:
		i = 0
		while True:
			if i + 1 > len(a) or i + 1 > len(b):
				break
			if a[len(a) - i - 1] == b[len(b) - i - 1]:
				i += 1
			else:
				break
		print(len(a) + len(b) - i * 2)

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def instr():
	return ''.join(insr())

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
main()


str1 = list(input())
str2 = list(input())
while len(str1) and len(str2):
	if str1[-1] == str2[-1]:
		str1.pop()
		str2.pop()
	else:
		break
print(len(str1) + len(str2))


S = input()
T = input()
nagasaS = len(S)
nagasaT = len(T)
nagaihou = max(len(S), len(T))
mijikaihou = min(len(S), len(T))
kezuri = nagaihou - mijikaihou
count = 0
if nagaihou == nagasaS:
	S = S[kezuri:nagaihou]
else:
	T = T[kezuri:nagaihou]
count += kezuri
if S == T:
	print(count)
	exit()
left = 0
right = len(T)
right2 = len(S)
if S[len(S) - 1] != T[len(T) - 1]:
	count += len(S) * 2
	print(count)
	exit()
while left <= right2:
	mid = (left + right2) // 2
	if S[mid:right] == T[mid:right] and S[mid - 1:right] != T[mid - 1:right]:
		break
	elif S[mid:right] == T[mid:right]:
		right2 = mid - 1
	elif S[mid:right] != T[mid:right]:
		left = mid + 1
count += mid * 2
print(count)


import math
s = input()
t = input()
if s == t:
	print(0)
elif len(t) == 0:
	print(len(s))
elif len(s) == 0:
	print(len(t))
else:
	s = s[::-1]
	t = t[::-1]
	d = 0
	e = 0
	for i in range(min(len(s), len(t))):
		if s[i] != t[i]:
			d = len(s) - i
			e = len(t) - i
			break
	r = d + e
	if r == 0:
		r = max(len(s), len(t)) - min(len(s), len(t))
	print(r)


x = input()
y = input()
t = len(x) + len(y)
a = len(x) - 1
b = len(y) - 1
if a > b:
	n = b
else:
	n = a
for i in range(n, -1, -1):
	if x[a] == y[b]:
		t -= 2
		a -= 1
		b -= 1
	else:
		break
print(t)


def compare(s1, s2):
	identical = 0
	for i in range(len(s2)):
		if s1[-1 - i] != s2[-1 - i]:
			return (identical, False)
		else:
			identical += 1
	return (identical, True)
s = input()
b = input()
if len(s) > len(b):
	(iden, _) = compare(s, b)
else:
	(iden, _) = compare(b, s)
print(len(s) + len(b) - 2 * iden)


(a, b) = (input(), input())
(al, bl) = (len(a), len(b))
(a, b) = (list(reversed(a)), list(reversed(b)))
(i, c) = (0, 0)
while True:
	try:
		if a[i] == b[i]:
			c += 2
		else:
			break
	except:
		break
	i += 1
print(al + bl - c)


a = input()
b = input()
a = a[::-1]
b = b[::-1]
alen = len(a)
blen = len(b)
lenlen = min(alen, blen)
dd = 0
for i in range(lenlen):
	if a[i] == b[i]:
		dd = dd + 1
	else:
		break
print(alen + blen - dd * 2)


l = str(input())
m = str(input())
x = l[::-1]
y = m[::-1]
if len(x) > len(y):
	n = len(y)
else:
	n = len(x)
count = 0
i = 0
check = True
while check and i < n:
	if x[i] == y[i]:
		count = count + 1
		check = True
		i = i + 1
	else:
		check = False
print(len(x) + len(y) - 2 * count)


s1 = input().strip()
s2 = input().strip()
n1 = len(s1)
n2 = len(s2)
t = min(n1, n2)
for i in range(min(n1, n2)):
	if s1[-i - 1] != s2[-i - 1]:
		t = i
		break
print(n1 - t + n2 - t)


s = input()
t = input()
n = len(s)
m = len(t)
while (n > 0 and m > 0) and s[n - 1] == t[m - 1]:
	n -= 1
	m -= 1
print(m + n)


from sys import stdin

def main():
	primera = stdin.readline().strip()
	segunda = stdin.readline().strip()
	i = len(primera) - 1
	j = len(segunda) - 1
	while primera[i] == segunda[j]:
		if i < 0 or j < 0:
			break
		i -= 1
		j -= 1
	print(i + 1 + (j + 1))
main()


s = input()
t = input()
count = 0
(m, n) = (len(s), len(t))
while m != 0 and n != 0:
	if s[m - 1] == t[n - 1]:
		count += 2
	else:
		break
	n -= 1
	m -= 1
print(len(s) + len(t) - count)


word1 = input()
word2 = input()
i = 1
m = min(len(word1), len(word2))
while i < m and word1[-i] == word2[-i]:
	i += 1
if word1[-i] != word2[-i]:
	i -= 1
print(len(word1) + len(word2) - 2 * i)


s1 = input()
s2 = input()
cnt = 0
i1 = len(s1) - 1
i2 = len(s2) - 1
while i1 >= 0 and i2 >= 0 and (s1[i1] == s2[i2]):
	cnt += 1
	i1 -= 1
	i2 -= 1
print(len(s1) + len(s2) - 2 * cnt)


try:
	s = input()
	t = input()
	ls = len(s)
	(c, flag) = (0, 1)
	lt = len(t)
	m = min(ls, lt)
	i = -1
	while flag and abs(i) <= m:
		if s[i] == t[i]:
			c = c + 1
		else:
			flag = 0
		i = i - 1
	k = ls + lt - 2 * c
	print(k)
except:
	pass


a = input()
b = input()
(c, d) = (len(a), len(b))
k = min(c, d)
cetak = c + d
for i in range(1, k + 1):
	if a[-i] == b[-i]:
		cetak -= 2
	else:
		break
print(cetak)


a = str(input())
b = str(input())
sum = 0
while 1:
	i = len(a) - sum - 1
	j = len(b) - sum - 1
	if i >= 0 and j >= 0 and (a[i] == b[j]):
		sum += 1
	else:
		break
print(len(a) + len(b) - 2 * sum)


s = str(input())
t = str(input())
l1 = len(s)
l2 = len(t)
count = 0
if l1 == 0 or l2 == 0:
	print(l1 + l2)
else:
	if s[l1 - 1] == t[l2 - 1]:
		for i in range(min(l1, l2)):
			ind1 = l1 - 1 - i
			ind2 = l2 - 1 - i
			if s[ind1] == t[ind2]:
				count += 1
			else:
				break
	print(l1 - count + l2 - count)


a = input()
a = list(a)
a.reverse()
b = input()
b = list(b)
b.reverse()
c = len(a)
d = len(b)
x = min(c, d)
for i in range(x):
	if a[i] != b[i]:
		break
if i + 1 == x and a[i] == b[i]:
	print(c + d - 2 * x)
else:
	print(c + d - 2 * i)


import re
import sys
exit = sys.exit
from bisect import bisect_left as bsl, bisect_right as bsr
from collections import Counter, defaultdict as ddict, deque
from functools import lru_cache
cache = lru_cache(None)
from heapq import *
from itertools import *
from math import inf
from pprint import pprint as pp
enum = enumerate
ri = lambda : int(rln())
ris = lambda : list(map(int, rfs()))
rln = sys.stdin.readline
rl = lambda : rln().rstrip('\n')
rfs = lambda : rln().split()
mod = 1000000007
d4 = [(0, -1), (1, 0), (0, 1), (-1, 0)]
d8 = [(-1, -1), (0, -1), (1, -1), (-1, 0), (1, 0), (-1, 1), (0, 1), (1, 1)]
s = rl()
t = rl()
n = max(len(s), len(t))
s = ('.' * n + s)[-n:]
t = ('.' * n + t)[-n:]
ans = k = 0
for i in range(n):
	if s[i] == '.' or t[i] == '.':
		ans += 1
	elif s[i] == t[i]:
		k += 2
	else:
		ans += 2 + k
		k = 0
print(ans)


a = input()
b = input()
(lena, lenb) = (len(a), len(b))
(x, y) = (lena, lenb)
i = 0
while 1:
	if a[lena - 1] == b[lenb - 1] and lena > 0 and (lenb > 0):
		lena -= 1
		lenb -= 1
		i += 1
	else:
		break
print(x - i + (y - i))


a = list(input())
b = list(input())
if len(a) < len(b):
	(a, b) = (b, a)
cnt = len(a) + len(b)
i = 1
c = 0
while True:
	if a[-i] == b[-i]:
		c = c + 1
		i = i + 1
	else:
		break
	if i > len(b):
		break
print(cnt - 2 * c)


def main():
	(s1, s2) = (input(), input())
	s1 = list(s1)
	s2 = list(s2)
	s1.reverse()
	s2.reverse()
	k = 0
	for i in range(min(len(s1), len(s2))):
		if s1[i] == s2[i]:
			k += 1
		else:
			break
	print(len(s1) + len(s2) - 2 * k)
main()


s = str(input())
t = str(input())
ans = len(s) + len(t)
ind = -1
s_len = len(s)
t_len = len(t)
while abs(ind) <= s_len and abs(ind) <= t_len and (s[ind] == t[ind]):
	ans -= 2
	ind -= 1
print(ans)


a = input()
b = input()
str1 = ''
str2 = ''
if len(a) < len(b):
	str1 = a
	str2 = b
else:
	str1 = b
	str2 = a
totallen = len(str1) + len(str2)
count = 0
for i in range(len(str1)):
	if str1[-1 - i] == str2[-1 - i]:
		count = count + 2
	else:
		break
print(totallen - count)


s = input()
k = input()
r = len(s) + len(k)
for (i, j) in zip(reversed(s), reversed(k)):
	if i != j:
		break
	else:
		r -= 2
print(r)


a = input()
b = input()
a = a[::-1]
b = b[::-1]
t = len(a) + len(b)
if len(a) > len(b):
	for i in range(len(b)):
		if a[i] == b[i]:
			t -= 2
		else:
			print(t)
			break
	else:
		print(t)
else:
	for j in range(len(a)):
		if a[j] == b[j]:
			t -= 2
		else:
			print(t)
			break
	else:
		print(t)


s1 = input()
s2 = input()
ls1 = len(s1) - 1
ls2 = len(s2) - 1
start = len(s1) + len(s2)
while ls1 >= 0 and ls2 >= 0:
	if s1[ls1] != s2[ls2]:
		break
	start -= 2
	ls1 -= 1
	ls2 -= 1
print(start)


a = input()
b = input()
i = len(a) - 1
p = len(b) - 1
l = 0
while i >= 0 and p >= 0:
	if a[i] != b[p]:
		print(len(a) - l + len(b) - l)
		exit()
	else:
		l = l + 1
		i = i - 1
		p = p - 1
print(len(a) - l + len(b) - l)
exit()


a = input()[::-1] + '-'
b = input()[::-1] + '+'
count = 0
while a[count] == b[count]:
	count += 1
print(len(a) - count - 1 + len(b) - count - 1)


a = str(input())
b = str(input())
f = 0
l1 = len(a)
l2 = len(b)
l = min(l1, l2)
for i in range(l):
	if a[l1 - i - 1] != b[l2 - i - 1]:
		f = 1
		break
if f == 0:
	i = i + 1
print(l1 + l2 - 2 * i)


import sys
lines = [line.strip() for line in sys.stdin.readlines()]
a = lines[0].split(' ')[0]
b = lines[1].split(' ')[0]
count = 0
i = len(a)
j = len(b)
while i != 0 and j != 0:
	if a[i - 1] != b[j - 1]:
		break
	else:
		count += 1
		i -= 1
		j -= 1
if count == 0:
	print(len(a) + len(b))
else:
	print(len(a) + len(b) - 2 * count)


a = input()
b = input()
count = 0
i = len(a)
j = len(b)
bool = True
while i >= 0 and j >= 0 and bool:
	i -= 1
	j -= 1
	bool = a[i] == b[j]
result = len(a) + len(b) - 2 * (len(a) - i - 1)
print(result)


s = list(input())
t = list(input())
ans = len(s) + len(t)
(a, b) = (len(s) - 1, len(t) - 1)
while a >= 0 and b >= 0:
	if s[a] == t[b]:
		ans -= 2
	else:
		break
	a -= 1
	b -= 1
print(ans)


pal1 = input()
pal2 = input()
aux1 = len(pal1) - 1
aux2 = len(pal2) - 1
while pal1[aux1] == pal2[aux2]:
	aux1 -= 1
	aux2 -= 1
	if aux1 < 0:
		break
	if aux2 < 0:
		break
print(aux1 + aux2 + 2)


s = input()
t = input()
ans = len(s) + len(t)
for (a, b) in zip(s[::-1], t[::-1]):
	if a == b:
		ans -= 2
	else:
		break
print(ans)


a = input().strip()
b = input().strip()
matches = 0
index = -1
while True:
	if -index > len(a) or -index > len(b):
		break
	if a[index] == b[index]:
		matches += 1
	else:
		break
	index -= 1
print(len(a) - matches + len(b) - matches)


string1 = input()
string2 = input()
i = len(string1) - 1
j = len(string2) - 1
temp = 0
while i >= 0 and j >= 0:
	if string1[i] == string2[j]:
		temp += 2
	else:
		break
	i -= 1
	j -= 1
print(len(string1) + len(string2) - temp)


str1 = input()
str2 = input()
n = len(str1)
m = len(str2)
i = n - 1
j = m - 1
while i >= 0 and j >= 0:
	if str1[i] != str2[j]:
		break
	else:
		i -= 1
		j -= 1
ans = i + 1 + (j + 1)
print(ans)


s = input()
t = input()
sum = 0
z = len(s) - 1
x = len(t) - 1
while s[z] == t[x]:
	z = z - 1
	x = x - 1
	if z < 0 or x < 0:
		break
sum = z + x + 2
print(sum)


from sys import stdin

def main():
	s = stdin.readline().strip()
	t = stdin.readline().strip()
	inv = 0
	while 1:
		i = len(s) - inv - 1
		j = len(t) - inv - 1
		if i >= 0 and j >= 0 and (s[i] == t[j]):
			inv += 1
		else:
			break
	print(len(s) + len(t) - 2 * inv)
main()


a = input()
b = input()
a = a[::-1]
b = b[::-1]
i = 0
d = abs(len(a) - len(b))
while i < len(a) and i < len(b):
	if a[i] == b[i]:
		i += 1
	else:
		print(2 * (min(len(a), len(b)) - i) + d)
		exit()
print(d)


word1 = str(input())
word2 = str(input())
l = len(word1) + len(word2)
word1 = word1[::-1]
word2 = word2[::-1]
for i in range(min(len(word1), len(word2))):
	if word1[i] == word2[i]:
		l = l - 2
	else:
		break
print(l)


x = input()
y = input()
i = len(x) - 1
j = len(y) - 1
count = 0
while x[i] == y[j] and i >= 0 and (j >= 0):
	count = count + 1
	i = i - 1
	j = j - 1
total = len(x) - count + len(y) - count
print(total)


s = input()
t = input()
sl = len(s)
tl = len(t)
c = sl + tl
i = -1
while s[i] == t[i]:
	if -i <= sl:
		c -= 1
	if -i <= tl:
		c -= 1
	i -= 1
	if -i > sl or -i > tl:
		break
print(c)


import sys
a = input()
b = input()
c = len(a)
d = len(b)
thislist = []
g = 0
pos = 0
if a[c - 1] == b[d - 1]:
	if c > d:
		for i in range(c - d, c):
			for j in range(g, d):
				g = g + 1
				if a[i] == b[j]:
					thislist.append(1)
				else:
					thislist.append(0)
				break
	elif c < d:
		for i in range(d - c, d):
			for j in range(g, c):
				g = g + 1
				if b[i] == a[j]:
					thislist.append(1)
				else:
					thislist.append(0)
				break
	else:
		for i in range(0, d):
			for j in range(g, c):
				g = g + 1
				if b[i] == a[j]:
					thislist.append(1)
				else:
					thislist.append(0)
				break
else:
	print(c + d)
	sys.exit()
h = len(thislist)
for k in range(h, 0, -1):
	if thislist[k - 1] == 1:
		continue
	else:
		pos = k
		break
f = c + d - 2 * (h - pos)
print(f)


a = input()
b = input()
count = -0
if a == b:
	print(0)
else:
	while count > -min(len(b), len(a)):
		if a[count - 1] == b[count - 1]:
			count -= 1
		else:
			break
		pass
	print(len(a) + len(b) + count * 2)


T = 1
for test in range(T):
	s1 = input()
	s2 = input()
	l1 = []
	l2 = []
	for i in range(len(s1) - 1, -1, -1):
		l1.append(s1[i])
	for i in range(len(s2) - 1, -1, -1):
		l2.append(s2[i])
	i = 0
	while True:
		try:
			if l1[i] == l2[i]:
				i += 1
			else:
				break
		except IndexError:
			break
	print(len(l1) + len(l2) - 2 * i)


def count(a, b):
	counter = 0
	if a[-1] != b[-1]:
		return len(a) + len(b)
	else:
		imin = min(len(a), len(b))
		for i in range(-1, 0 - (imin + 1), -1):
			if a[i] == b[i]:
				counter += 1
			else:
				break
		return len(a) - counter + len(b) - counter
a = input()
b = input()
print(count(a, b))


s = list(map(str, input().split()))
s = str(s[0])
t = list(map(str, input().split()))
t = str(t[0])
minlen = min(len(s), len(t))
ok = True
ch = 0
for i in range(minlen):
	if ok == True:
		if s[-(i + 1)] != t[-(i + 1)]:
			ok = False
			ch = i
if ok == True:
	ch = minlen
print(len(s) + len(t) - 2 * ch)


s = input()
t = input()
counter = 0
outcome = 0
if s == '' or t == '':
	counter = 0
else:
	S = list(s)
	T = list(t)
	while S[-1] == T[-1]:
		del S[-1]
		del T[-1]
		counter += 2
		if len(S) > 0 and len(T) > 0:
			continue
		else:
			break
outcome = len(s) + len(t) - counter
print(outcome)


a = input().strip()
b = input().strip()
ans = 0
ai = len(a) - 1
bi = len(b) - 1
while ai >= 0 and bi >= 0:
	if a[ai] == b[bi]:
		ans += 2
	else:
		break
	ai -= 1
	bi -= 1
print(len(a) + len(b) - ans)


def move(s):
	s = str(s)
	return s[1:len(s)]

def main():
	s = input()
	t = input()
	toplam = len(s) + len(t)
	sayac = 0
	for i in range(1, min(len(s), len(t)) + 1):
		if s[len(s) - i] != t[len(t) - i]:
			break
		else:
			sayac += 1
	print(toplam - sayac * 2)
main()


s = input()
t = input()
cmn = 0
while cmn < len(s) and cmn < len(t) and (s[-cmn - 1] == t[-cmn - 1]):
	cmn += 1
print(len(s) + len(t) - 2 * cmn)


a = list(input())
b = list(input())
a.reverse()
b.reverse()
i = 0
while i < min(len(a), len(b)) and a[i] == b[i]:
	i += 1
print(len(a) + len(b) - 2 * i)


a = input()
b = input()
count = 0
n1 = len(a)
n2 = len(b)
i = n1 - 1
j = n2 - 1
while a[i] == b[j] and i >= 0 and (j >= 0):
	count += 1
	i -= 1
	j -= 1
print(n1 + n2 - 2 * count)


import sys, math
mod = 10 ** 9 + 7
INF = float('inf')

def inp():
	return int(sys.stdin.readline())

def inpl():
	return list(map(int, sys.stdin.readline().split()))
s = input()
t = input()
n = len(s)
m = len(t)
if n > m:
	(s, t) = (t, s)
	(n, m) = (m, n)
res = m - n
t = t[m - n:]
for i in range(len(t))[::-1]:
	if s[i] != t[i]:
		res += (i + 1) * 2
		break
print(res)


firstString = input()
secondString = input()
counter = 0
while 1:
	i = len(firstString) - counter - 1
	j = len(secondString) - counter - 1
	if i >= 0 and j >= 0 and (firstString[i] == secondString[j]):
		counter += 1
	else:
		break
print(len(secondString) + len(firstString) - 2 * counter)


s = input()
t = input()
sind = len(s) - 1
tind = len(t) - 1
kRavn = 0
while sind >= 0 and tind >= 0 and (s[sind] == t[tind]):
	sind -= 1
	tind -= 1
	kRavn += 1
print(len(s) + len(t) - 2 * kRavn)


s = input()
t = input()
si = len(s) - 1
ti = len(t) - 1
while s[si] == t[ti]:
	si -= 1
	ti -= 1
	if si < 0 or ti < 0:
		break
print(2 + si + ti)


a = input().strip()
b = input().strip()
tail = 0
for i in range(min(len(a), len(b))):
	if a[-(i + 1)] != b[-(i + 1)]:
		tail = i
		break
	tail = i + 1
print(len(a) + len(b) - 2 * tail)


x = input()
y = input()
if len(x) >= len(y):
	ln = x
	sh = y
else:
	ln = y
	sh = x
count = 0
for i in range(len(sh)):
	if ln[-(i + 1)] == sh[-(i + 1)]:
		count += 1
	else:
		break
print(len(ln) + len(sh) - 2 * count)


count = 0
s = input()
t = input()
sl = len(s)
tl = len(t)
ls = sl
lt = tl
while s[ls - 1] == t[lt - 1]:
	count += 1
	lt -= 1
	ls -= 1
	if lt == 0 or ls == 0:
		break
s = tl + sl - 2 * count
print(s)


st1 = input()
st2 = input()
l1 = len(st1)
l2 = len(st2)
i = l1 - 1
j = l2 - 1
while st1[i] == st2[j]:
	i -= 1
	j -= 1
	if i < 0 or j < 0:
		break
print(i + j + 2)


import sys, math, itertools, collections, bisect
input = lambda : sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf')
mod = 10 ** 9 + 7
mans = inf
ans = 0
count = 0
pro = 1
s = input()
t = input()
n = min(len(s), len(t))
for i in range(1, n + 1):
	if s[-i] == t[-i]:
		count += 1
	else:
		break
print(len(s) + len(t) - count * 2)


a = list(input())
b = list(input())
if len(a) > len(b):
	count = len(b)
else:
	count = len(a)
start = -1
for x in range(count):
	if a[start] == b[start]:
		start -= 1
	else:
		break
move = 0
move += len(b) - start * -1 + 1
move += len(a) - start * -1 + 1
print(move)


s1 = list(reversed(list(input())))
s2 = list(reversed(list(input())))
n = min(len(s1), len(s2))
ans = len(s1) + len(s2)
for i in range(n):
	if s1[i] == s2[i]:
		ans -= 2
	else:
		break
print(ans)


a = input()[::-1]
b = input()[::-1]
c = len(a)
d = len(b)
z = min(c, d)
s = 0
for i in range(z):
	if a[i] != b[i]:
		break
	s += 1
print(c + d - 2 * s)


s = input()
t = input()
a = len(s)
b = len(t)
i = 0
j = 0
count = 0
c = 0
if s == t:
	print(count)
else:
	if a < b:
		count = b - a
		j = b - a
	elif a > b:
		count = a - b
		i = a - b
	for x in range(min(a, b)):
		if s[i] != t[j]:
			count += 2 + c
			i += 1
			j += 1
			c = 0
		else:
			i += 1
			j += 1
			c += 2
	print(count)


import math
from collections import defaultdict
ll = lambda : map(int, input().split())
ii = lambda : int(input())
x = list(input())
y = list(input())
z = min(len(x), len(y))
x = x[::-1]
y = y[::-1]
i = 0
while i < z:
	if x[i] != y[i]:
		break
	i += 1
print((z - i) * 2 + abs(len(x) - len(y)))


from sys import stdin, stdout
input = lambda : stdin.readline().rstrip()
write = stdout.write

def main():
	S = input()
	T = input()
	if S == T:
		print(0)
		return
	(S, T) = (S[::-1], T[::-1])
	(ls, lt) = (len(S), len(T))
	n = min(ls, lt)
	for i in range(n):
		if S[i] != T[i]:
			i -= 1
			break
	ans = ls + lt - (i + 1) * 2
	print(ans)
main()


a = input()
b = input()
a = a[::-1]
b = b[::-1]
a1 = len(a)
b1 = len(b)
count = 0
if a1 <= b1:
	(a, b) = (b, a)
	(a1, b1) = (b1, a1)
for x in range(b1):
	if a[x] != b[x]:
		break
	else:
		count += 1
print(a1 - count + (b1 - count))


strA = input()
strB = input()
endA = len(strA) - 1
endB = len(strB) - 1
while strA[endA] == strB[endB] and endA >= 0 and (endB >= 0):
	endA -= 1
	endB -= 1
print(endA + endB + 2)


s = input()
t = input()
moves = 0
ls = len(s)
lt = len(t)
ml = min(ls, lt)
i = 1
while i <= ml and s[-i] == t[-i]:
	i += 1
i -= 1
if i == 0:
	g = ''
else:
	g = s[-i:]
lg = len(g)
moves = ls + lt - 2 * lg
print(moves)


x = input()[::-1]
y = input()[::-1]
a = 0
for (i, e) in zip(x, y):
	if i != e:
		break
	a += 1
print(len(x + y) - 2 * a)


s = input()
t = input()
s1 = len(s)
t1 = len(t)
s = s[::-1]
t = t[::-1]
count = 0
if s1 < t1:
	for i in range(s1):
		if s[i] == t[i]:
			count = count + 1
		else:
			break
else:
	for i in range(t1):
		if s[i] == t[i]:
			count = count + 1
		else:
			break
print(s1 + t1 - 2 * count)


s1 = list(input())
s2 = list(input())
l1 = len(s1)
l2 = len(s2)
m = min(l1, l2)
c = 0
for i in range(m):
	if s1[l1 - 1 - i] == s2[l2 - 1 - i]:
		c += 1
	else:
		break
print(l2 + l1 - 2 * c)


s = input()
t = input()
j = len(t) - 1
count = 0
for i in range(len(s)):
	if s[len(s) - i - 1] == t[j]:
		j -= 1
		count += 1
		if j < 0:
			break
	else:
		break
print(len(s) + len(t) - 2 * count)


s = input()
t = input()
i = len(s)
j = len(t)
if s[i - 1] != t[j - 1]:
	print(i + j)
else:
	r = 0
	for z in range(min(i, j)):
		if s[i - 1 - z] == t[j - 1 - z]:
			r += 1
		else:
			break
	print(i + j - 2 * r)


x = input()
y = input()
xx = []
yy = []
for i in range(len(x) - 1, -1, -1):
	xx.append(x[i])
for i in range(len(y) - 1, -1, -1):
	yy.append(y[i])
i = 0
j = 0
while i < len(x) and j < len(y) and (xx[i] == yy[j]):
	i += 1
	j += 1
print(len(x) + len(y) - 2 * i)


entrada = []
count = 0
for i in range(2):
	entrada.append(input()[::-1])
for i in range(len(max(entrada, key=len))):
	try:
		if entrada[0][i] == entrada[1][i]:
			count += 1
		else:
			break
	except:
		break
print(len(entrada[0]) + len(entrada[1]) - count * 2)


ch = input()
cha = input()
i = len(ch) - 1
j = len(cha) - 1
while i >= 0 and j >= 0 and (ch[i] == cha[j]):
	i -= 1
	j -= 1
print(i + j + 2)


s = input()
t = input()
pos = 0
flag = False
for i in range(1, min(len(s), len(t)) + 1):
	if s[-i] != t[-i]:
		pos = i - 1
		flag = True
		break
if not flag:
	pos = min(len(s), len(t))
print(len(s) + len(t) - 2 * pos)


s = list(input())
t = list(input())
n = len(s)
m = len(t)
sum1 = m + n
count = 0
i = 0
while 1:
	if i == n or i == m:
		break
	elif s[n - i - 1] == t[m - i - 1]:
		count = count + 1
		i = i + 1
	else:
		break
print(sum1 - 2 * count)


s1 = input()
s2 = input()
i = len(s1) - 1
j = len(s2) - 1
pre = 0
while i >= 0 and j >= 0:
	if s1[i] != s2[j]:
		break
	else:
		pre += 1
	i -= 1
	j -= 1
ans = len(s1) + len(s2) - 2 * pre
print(ans)


a = str(input())
b = str(input())
a = a[::-1]
b = b[::-1]
na = len(a)
nb = len(b)
d = abs(na - nb)
l = min(na, nb)
k = 0
for i in range(0, l):
	if a[i] != b[i]:
		k = (l - i) * 2
		break
print(d + k)


import sys
s = input()
t = input()
t = list(t)
s = list(s)
f = 0
ans = 0
if s[-1] != t[-1]:
	print(len(s) + len(t))
	sys.exit()
k = min(len(s), len(t))
for i in range(1, k + 1):
	if t[-i] == s[-i]:
		f += 1
		continue
	else:
		break
ans = len(s) - f + (len(t) - f)
print(ans)


str1 = input()
str2 = input()
l1 = len(str1)
l2 = len(str2)
state = True
i = -1
while state and i >= -1 * l1 and (i >= -1 * l2):
	if str1[i] == str2[i]:
		i -= 1
	else:
		state = False
print(l1 + l2 + i + i + 2)


s = str(input())
t = str(input())
n = len(s)
m = len(t)
while s[n - 1] == t[m - 1]:
	if n == 0 or m == 0:
		break
	n = n - 1
	m = m - 1
print(n + m)


a = input()
x = len(a)
b = input()
y = len(b)
i = 1
while i <= x and i <= y and (a[-i] == b[-i]):
	i += 1
print(x + y - 2 * i + 2)


li1 = []
li2 = []
li1 = input()
li2 = input()
n = len(li1)
m = len(li2)
p = n + m
c = 0
if n >= m:
	for i in range(0, m):
		if li2[m - i - 1] == li1[n - i - 1]:
			c = c + 1
		else:
			break
else:
	for i in range(0, n):
		if li2[m - i - 1] == li1[n - i - 1]:
			c = c + 1
		else:
			break
print(p - c * 2)


s = str(input())
t = str(input())
ans = 0
for i in range(len(s) - 1, 0 - 1, -1):
	for j in range(len(t) - 1, 0 - 1, -1):
		if s[i] != t[j]:
			ans = i + j + 2
			break
		else:
			i = i - 1
			j = j - 1
	break
if len(s) != len(t) and ans == 0:
	print(abs(len(s) - len(t)))
else:
	print(ans)


from math import ceil, log, floor, sqrt
import math
k = 1

def mod_expo(n, p, m):
	result = 1
	while p != 0:
		if p % 2 == 1:
			result = result * n % m
		p //= 2
		n = n * n % m
	return result

def is_prime(n):
	m = 2
	while m * m <= n:
		if n % m == 0:
			return False
		m += 1
	return True

def find_sum(n, a):
	a.insert(0, 0)
	for i in range(1, n + 1):
		prev = a[i] & a[i - 1]
		cur = a[i] | a[i - 1]
		a[i - 1] = prev
		a[i] = cur
	return sum((m * m for m in a))

def prin_abc(x, y, z):
	l = [x, y, z]
	l.sort()
	if l[1] < l[2]:
		print('NO')
		return
	a = b = l[0]
	c = l[2]
	print('YES')
	print(a, b, c)

def get_scores(n, vals):
	l = 0
	r = n - 1
	turn = 0
	sereja = 0
	dima = 0
	while l <= r:
		if vals[l] > vals[r]:
			cur = vals[l]
			l += 1
		else:
			cur = vals[r]
			r -= 1
		if turn == 0:
			sereja += cur
		else:
			dima += cur
		turn = not turn
	print(sereja, dima)

def count_lamps(n, m):
	return (n * m + 1) // 2

def get_cnt(a, b):
	m = len(a)
	n = len(b)
	cnt = m + n
	while m > 0 and n > 0:
		if a[m - 1] != b[n - 1]:
			return cnt
		m -= 1
		n -= 1
		cnt -= 2
	return cnt
t = 1
while t:
	t = t - 1
	(k, g) = (0, 0)
	points = []
	a = input()
	b = input()
	print(get_cnt(a, b))


s = input()
t = input()
n = len(s)
m = len(t)
i = n - 1
j = m - 1
ans = 0
while i >= 0 and j >= 0:
	if s[i] != t[j]:
		ans = i + j + 2
		break
	i -= 1
	j -= 1
if ans == 0:
	ans = i + j + 2
print(ans)


Input = lambda : map(int, input().split())
s = input()
t = input()
LenS = len(s)
LenT = len(t)
i = LenS - 1
j = LenT - 1
while i >= 0 and j >= 0 and (s[i] == t[j]):
	i -= 1
	j -= 1
ans = LenS - (LenS - i - 1)
ans += LenT - (LenT - j - 1)
print(ans)


a = list(input())
b = list(input())
n = len(a)
m = len(b)
x = abs(n - m)
na = n - 1
nb = m - 1
moves = 0
for i in range(max(n, m)):
	if a[na] != b[nb]:
		if n > m:
			moves = x + 2 * (na + 1 - x)
		else:
			moves = x + 2 * (nb + 1 - x)
		break
	na -= 1
	nb -= 1
	if na < 0 or nb < 0:
		moves = abs(n - m)
		break
print(moves)


a = input('')
b = input('')
p = 0
l = 0
t = []
z = []
c = len(a)
d = len(b)
s = 0
if len(a) < len(b):
	n = len(a)
else:
	n = len(b)
for i in range(len(a)):
	t.append(a[p])
	p = p + 1
for kl in range(len(b)):
	z.append(b[l])
	l = l + 1
t.reverse()
z.reverse()
for kli in range(n):
	if not t[s] == z[s]:
		break
	s = s + 1
e = c - s
f = d - s
x = f + e
print(x)


s = input()
t = input()
l1 = len(s)
l2 = len(t)
cnt = 0
j = 1
if l2 > l1:
	(s, t) = (t, s)
	(l1, l2) = (l2, l1)
if s[-1] != t[-1]:
	print(l1 + l2)
	exit(0)
for i in range(l2 - 1, -1, -1):
	if s[l1 - j] != t[i]:
		break
	else:
		cnt += 1
	j += 1
print(l1 + l2 - cnt * 2)


from sys import stdin
hat = stdin.readlines()
str1 = list(hat[0])
str2 = list(hat[1])
total = len(str1) + len(str2)
if len(str2) > len(str1):
	(str1, str2) = (str2, str1)
if str1 == str2:
	print(0)
	quit()
elif str1[-1] != str2[-1]:
	print(total)
	quit()
str1.reverse()
str2.reverse()
for i in range(len(str2)):
	if str2[i] != str1[i]:
		print(total - i * 2)
		quit()
print(len(str1) - len(str2))


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
from math import sqrt, floor, factorial, gcd
from collections import deque, Counter, defaultdict
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from collections import deque
input = lambda : sys.stdin.readline().rstrip('\r\n')
read = lambda : list(map(int, input().split(' ')))

def func(arr):
	return sum([arr[i] for i in range(0, len(arr), 2)])

def solve():
	s = input()
	t = input()
	ans = len(s) + len(t)
	for i in range(-1, -min(len(s), len(t)) - 1, -1):
		if s[i] == t[i]:
			ans -= 2
		else:
			break
	print(ans)
solve()


s = input()[::-1] + '1'
t = input()[::-1] + '2'
i = 0
while s[i] == t[i]:
	i = i + 1
print(len(s) - 1 - i + (len(t) - 1 - i))


def main():
	(s, t) = (input(), input())
	for (i, a, b) in zip(range(len(s) + len(t), -2, -2), [*s[::-1], '?'], [*t[::-1], '!']):
		if a != b:
			print(i)
			break
main()


from sys import stdin
s = stdin.readline().strip()
t = stdin.readline().strip()
pre = [False] * max(len(s), len(t))
i = len(s) - 1
j = len(t) - 1
k = len(pre) - 1
while i >= 0 and j >= 0 and (k >= 0):
	if s[i] == t[j]:
		pre[k] = True
		i -= 1
		j -= 1
		k -= 1
	else:
		break
while k >= 0:
	pre[k] = False
	k -= 1
i = 0
j = 0
k = 0
ans = 0
if len(s) > len(t):
	while len(s) - i > len(t):
		i += 1
		k += 1
		ans += 1
elif len(t) > len(s):
	while len(t) - j > len(s):
		j += 1
		k += 1
		ans += 1
while i < len(s) and j < len(t) and (k < len(pre)):
	if pre[k] == False:
		ans += 2
	else:
		break
	i += 1
	j += 1
	k += 1
print(ans)


n = input()
m = input()
a = len(n)
b = len(m)
i = a - 1
j = b - 1
if n[-1] != m[-1]:
	print(a + b)
else:
	while i >= 0 and j >= 0:
		if n[i] != m[j]:
			break
		i -= 1
		j -= 1
	print(i + j + 2)


s = input()
t = input()
c = 0
for (i, j) in zip(range(len(s) - 1, -1, -1), range(len(t) - 1, -1, -1)):
	if s[i] == t[j]:
		c += 2
	else:
		break
print(len(s) + len(t) - c)


s1 = input()
s2 = input()
i1 = len(s1) - 1
i2 = len(s2) - 1
flag = True
ans = i1 + i2 + 2
while flag and i1 >= 0 and (i2 >= 0):
	if s1[i1] == s2[i2]:
		ans -= 2
		i1 -= 1
		i2 -= 1
	else:
		flag = False
print(ans)


s = input()
t = input()
n = len(s)
m = len(t)
i = n - 1
j = m - 1
count = 0
while i >= 0 and j >= 0 and (s[i] == t[j]):
	count += 1
	i -= 1
	j -= 1
print(m + n - count * 2)


s1 = input().strip()
s2 = input().strip()
N = 0
L = len(s1)
if len(s1) > len(s2):
	L = len(s2)
for i in range(1, L + 1):
	if s1[-i] == s2[-i]:
		N += 1
	else:
		break
print(len(s1) + len(s2) - 2 * N)


first = list(input())
second = list(input())
while 1:
	if second[-1] == first[-1]:
		second.pop()
		first.pop()
	else:
		break
	if len(first) == 0 or len(second) == 0:
		break
print(len(first) + len(second))


s = input()
t = input()
is_equal = False
steps = 0
ind = 1
while len(s) >= ind and len(t) >= ind and (s[len(s) - ind] == t[len(t) - ind]):
	ind += 1
ind -= 1
print(len(s) + len(t) - 2 * ind)


a = input()
b = input()
cnt = 0
a = a[::-1]
b = b[::-1]
if len(a) <= len(b):
	for i in range(len(a)):
		if a[i] == b[i]:
			cnt += 1
		else:
			break
else:
	for i in range(len(b)):
		if a[i] == b[i]:
			cnt += 1
		else:
			break
print(len(a) + len(b) - cnt * 2)


a = input()
b = input()
i = len(a)
j = len(b)
(x, y) = (i - 1, j - 1)
while x >= 0 and y >= 0:
	if a[x] == b[y]:
		x -= 1
		y -= 1
		continue
	break
print(x + 1 + y + 1)


str1 = input()
str2 = input()
suffix = 0
(i, j) = (len(str1) - 1, len(str2) - 1)
m = i + 1
n = j + 1
big = max(m, n)
small = min(m, n)
while str1[i] == str2[j] and (i >= 0 and j >= 0):
	suffix += 1
	i -= 1
	j -= 1
if suffix == 0:
	print(m + n)
elif suffix == big:
	print(0)
else:
	print(m + n - 2 * suffix)


a = input()
b = input()
n = len(a)
m = len(b)
ans = 0
if n > m:
	a = a[n - m:]
	ans += n - m
elif n < m:
	b = b[m - n:]
	ans += m - n
n = min(n, m)
i = n - 1
tec_ans = 2 * n
while a[i] == b[i] and i > -1:
	tec_ans = i * 2
	i -= 1
print(ans + tec_ans)


a = input()
b = input()
la = len(a)
lb = len(b)
i = 1
com = 0
while i <= min(la, lb):
	if a[-i] != b[-i]:
		break
	else:
		com += 1
	i += 1
ans = la + lb - 2 * com
print(ans)


a = input()
b = input()
if len(a) > len(b):
	(a, b) = (b, a)
i = 0
ans = 0
while i < len(a):
	if a[len(a) - i - 1] != b[len(b) - i - 1]:
		ans = len(b) + len(a) - 2 * i
		break
	else:
		ans = len(b) - len(a)
	i = i + 1
print(ans)


s1 = input()
s2 = input()
m_len = 0
s1_l = len(s1)
s2_l = len(s2)
for (i, j) in zip(range(s1_l - 1, -1, -1), range(s2_l - 1, -1, -1)):
	if s1[i] == s2[j]:
		m_len += 1
	else:
		break
ans = 0
if m_len == s1_l and m_len == s2_l:
	print(0)
else:
	ans = s1_l + s2_l - 2 * m_len
	print(ans)


string1 = input()
string2 = input()
x = len(string1)
y = len(string2)
while string1[x - 1] == string2[y - 1] and x > 0 and (y > 0):
	x -= 1
	y -= 1
print(x + y)


a = input()
b = input()
a = a[::-1]
b = b[::-1]
if len(a) > len(b):
	(a, b) = (b, a)
tot = len(a) + len(b)
for k in range(len(a)):
	if a[k] == b[k]:
		tot -= 2
	else:
		break
print(tot)


s = input()
s2 = input()
if len(s2) > len(s):
	(s2, s) = (s, s2)
k = 0
for i in range(len(s2)):
	if s2[len(s2) - i - 1] != s[len(s) - i - 1]:
		break
	k += 1
print(len(s2) + len(s) - 2 * k)


a = input()
b = input()
c = a[::-1]
d = b[::-1]
k = len(a) + len(b)
j = 0
u = min(len(a), len(b))
while j < u and c[j] == d[j]:
	j += 1
print(k - j * 2)


s = list(input())
t = list(input())
c = 0
while 1:
	i = len(s) - 1 - c
	j = len(t) - 1 - c
	if i >= 0 and j >= 0 and (s[i] == t[j]):
		c += 1
	else:
		break
print(len(s) + len(t) - 2 * c)


s1 = list(input())
s2 = list(input())
sl1 = len(s1)
sl2 = len(s2)
c = 0
b = 0
s1.reverse()
s2.reverse()
if sl1 > sl2:
	s1 = s1[:sl2]
	c = sl1 - sl2
elif sl2 > sl1:
	s2 = s2[:sl1]
	c = sl2 - sl1
else:
	c = 0
for (i, j) in zip(s1, s2):
	if i != j:
		break
	else:
		b += 2
print(len(s1) + len(s2) - b + c)


s = input()
v = input()
a = len(s)
b = len(v)
n = 0
if a >= b:
	for k in range(0, b):
		if s[a - 1 - k] != v[b - 1 - k]:
			n = k
			break
		n = b
	print(a - n + b - n)
else:
	for k in range(0, a):
		if s[a - 1 - k] != v[b - 1 - k]:
			n = k
			break
		n = a
	print(a - n + b - n)


s1 = input()
s2 = input()
s1 = s1[::-1]
s2 = s2[::-1]
(i, c) = (0, 0)
while i < len(s1) and i < len(s2):
	if s1[i] != s2[i]:
		break
	else:
		c += 1
	i += 1
print(len(s1) + len(s2) - 2 * c)


(s, t) = (input(), input())
i = 1
while i <= min(len(s), len(t)):
	if not s[-i] == t[-i]:
		break
	i += 1
i -= 1
print(len(s) - i + len(t) - i)


s = input()
t = input()
if s == t:
	print('0')
elif s.endswith(t):
	print(len(s) - len(t))
elif t.endswith(s):
	print(len(t) - len(s))
else:
	res = len(s) + len(t)
	i1 = len(s)
	i2 = len(t)
	if [1, 2][1] == 2:
		i1 -= 1
		i2 -= 1
	while s[i1] == t[i2]:
		res -= 2
		i1 -= 1
		i2 -= 1
	print(res)


I = lambda : [int(i) for i in input().split()]
s = input()
t = input()
n1 = len(s)
n2 = len(t)
if s[-1] != t[-1]:
	print(n1 + n2)
else:
	k = 0
	i = n1 - 1
	j = n2 - 1
	while i >= 0 and j >= 0:
		if s[i] != t[j]:
			break
		i -= 1
		j -= 1
	print(i + j + 2)


i = 0
a = input()
b = input()
while True:
	if i >= len(a) or i >= len(b):
		if i != min(len(a), len(b)):
			i = max(len(a), len(b))
		break
	if a[-(i + 1)] != b[-(i + 1)]:
		break
	i += 1
print(len(a) - i + len(b) - i)


s1 = input()
s2 = input()
k = 0
n1 = len(s1)
n2 = len(s2)
for i in range(-1, -min(n1, n2) - 1, -1):
	if s1[i] == s2[i]:
		k += 1
	else:
		break
print(n1 - k + n2 - k)


s1 = input().strip()
s2 = input().strip()
s1 = s1[::-1]
s2 = s2[::-1]
f = 0
for i in range(min(len(s1), len(s2))):
	if s1[i] != s2[i]:
		f = 1
		break
if f == 1:
	ans = 0
	ans += len(s1) - i
	ans += len(s2) - i
	print(ans)
else:
	print(max(len(s1), len(s2)) - (i + 1))


first = input()
second = input()
string1 = list(first)
string2 = list(second)
len1 = len(string1)
len2 = len(string2)
len1 = len1 - 1
len2 = len2 - 1
matchLen = 0
while len1 != -1 and len2 != -1:
	if string1[len1] == string2[len2]:
		matchLen = matchLen + 1
	else:
		break
	len1 = len1 - 1
	len2 = len2 - 1
print(len(string1) + len(string2) - matchLen * 2)


s = str(input())
t = str(input())
s = s[::-1]
t = t[::-1]
i = 0
c = 0
d = min(len(s), len(t))
while i < d:
	while s[i] == t[i]:
		c = c + 1
		i = i + 1
		if i >= d:
			break
	i = len(s)
print(len(s) + len(t) - 2 * c)


x = input()
y = input()
xp = len(x) - 1
yp = len(y) - 1
while xp >= 0 and yp >= 0 and (x[xp] == y[yp]):
	xp -= 1
	yp -= 1
ans = xp + yp + 2
print(ans)


s = input()
t = input()
le = 0
while True:
	i = len(s) - le - 1
	k = len(t) - le - 1
	if i >= 0 and k >= 0 and (s[i] == t[k]):
		le += 1
	else:
		break
print(len(s) + len(t) - 2 * le)


a = list(input())
b = list(input())
a.reverse()
b.reverse()
if len(a) < len(b):
	(a, b) = (b, a)
c = 0
j = 0
for i in range(len(a)):
	if j == len(b) or a[i] != b[j]:
		break
	else:
		c += 1
		j += 1
print(len(a) + len(b) - 2 * c)


(s, t) = (input(), input())
(m, n) = (len(s), len(t))
print(m + n - 2 * next((i for (i, (x, y)) in enumerate(zip(s[::-1], t[::-1])) if x != y), min(m, n)))


(s, t) = (input(), input())
(x, y) = (len(s), len(t))
while x * y * (s[x - 1] == t[y - 1]):
	x -= 1
	y -= 1
print(x + y)