We need to find the length of the longest uncommon subsequence (LUS). The definition: given two strings a and b, the longest uncommon subsequence is the longest string that is a subsequence of one of them and not a subsequence of the other. Note: Any string that is a subsequence of exactly one of the two strings qualifies. The empty string is a subsequence of both, so not uncommon unless one doesn't have it? Actually empty string is subsequence of any string, so it's common. So we need longest length L such that there exists a string s of length L where (s is subsequence of a and not of b) OR (s is subsequence of b and not of a). Return -1 if no such s exists (i.e., all subsequences are common). But careful: The problem statement: "longest string that is a subsequence of one of them and not a subsequence of the other." So we need to maximize length of such string. If none, output -1.
Observations: If a and b are equal, then any subsequence of a is also a subsequence of b? Not necessarily: if strings are identical, then the set of subsequences of a equals set of subsequences of b, so there is no uncommon subsequence (except maybe strings that are subsequence of a but not b? They have the same set). So output -1. But what if a != b? Then there is always some uncommon subsequence? Consider a="a", b="aa"? Let's test: Subsequences of a: {"", "a"}. Subsequences of b: {"", "a", "aa"}. So "aa" is a subsequence of b but not of a. So length 2. So if strings differ, we can often take the longer string itself if it is not a subsequence of the other. But careful: Could there be a scenario where all subsequences of one are also subsequences of the other, even though strings differ? For example, a="a", b="ab"? Subsequences of a: "", "a". Subsequences of b: "", "a", "b", "ab". "b" is subsequence of b not of a. So yes exists. But is there a case where both strings are such that each subsequence of one is also subsequence of the other? That would imply they have identical subsequence sets. That only happens if the strings are equal? Possibly not; consider a="ab", b="ba". Subsequences of "ab": "", a, b, ab. Subsequences of "ba": "", b, a, ba. Are they same? "ab" is subsequence of "ab" but not of "ba" because order matters. "ab" is not subsequence of "ba" (you can get a then b? ba: b then a, so a after b, can't get a before b). So "ab" is an uncommon subsequence. So indeed if strings are not identical, there is at least one uncommon subsequence? Consider a="a", b="b"? Subsequences: a has "a", b has "b". "a" is uncommon (subsequence of a but not b). So yes. But consider a="ab", b="abc"? Subsequences of b: include "c" and strings with c, also longer ones. "c" is subsequence of b not a. So exists. So maybe the only case where no uncommon subsequence exists is when a == b. However the problem statement says "If there's no uncommon subsequence, print '-1'." Could there be other cases? Let's think deeper: The empty string is common. For any non-empty string s, if s is subsequence of both, it's common. If s is subsequence of neither? That doesn't count because we need s to be subsequence of exactly one. But does there exist a case where every string is either subsequence of both or subsequence of none? That seems impossible because each string itself is a subsequence of itself. So at least one of a or b is a subsequence of itself but might also be a subsequence of the other. So if a is not a subsequence of b, then a is an uncommon subsequence (subsequence of a, not b). Similarly if b is not a subsequence of a, then b is an uncommon subsequence. So if a != b, could it happen that a is a subsequence of b and b is a subsequence of a? That would imply they are equal (if each is subsequence of the other, then they must have same length and characters in same order, i.e., they are equal). Because if a is subsequence of b, then len(a) <= len(b). If b is subsequence of a, then len(b) <= len(a). So lengths equal, and since they are subsequences of each other, they must be identical (the only way a string of same length is subsequence of another is if they are identical). So indeed, if a != b, then at least one of a is not a subsequence of b, or b is not a subsequence of a. So then we can take that longer string (or whichever not subsequence) as an uncommon subsequence. However, careful: If a is not a subsequence of b, then a itself is an uncommon subsequence (since it is subsequence of a). So the length would be len(a). Similarly if b is not subsequence of a, length len(b). But maybe there is an even longer string? Could there be a longer string that is subsequence of one but not the other? The maximum possible length of a subsequence of a is len(a). So the longest uncommon subsequence can't exceed max(len(a), len(b)). So if either string is not a subsequence of the other, then max(len(a), len(b)) is achievable (by taking that whole string). But what if the longer string is a subsequence of the shorter one? That can't happen because longer cannot be subsequence of shorter. So if len(a) != len(b), the longer string is definitely not a subsequence of the shorter (since length bigger). Therefore it's automatically an uncommon subsequence. So answer would be max(len(a), len(b)). But if lengths equal and strings differ, then neither is a subsequence of the other (since equal length but different content means one cannot be subsequence of the other, because subsequence of same length requires equality). So then again both are not subsequences of each other? Actually if equal length but different, then a is not a subsequence of b (since they differ) and b is not a subsequence of a. So we can pick either whole string, length = len(a) = len(b). So answer would be len(a) (or len(b)). So indeed for any a != b, answer is max(len(a), len(b)). For a == b, answer -1.
But wait: The problem statement examples: first example a="abcd", b="defgh". Lengths: 4 and 5. max = 5, output 5. That matches. Second example a="a", b="a" equal => -1. So this seems trivial. However, could there be a scenario where the longer string is a subsequence of the shorter? That's impossible due to length. So the answer indeed seems to be max length if strings different, else -1.
But let's double-check the definition: "longest string that is a subsequence of one of them and not a subsequence of the other." This means we consider strings that are subsequence of exactly one of a or b. So as argued, if a != b, at least one of a, b is not a subsequence of the other. But what about the case where a is a subsequence of b? Then a is not uncommon because it's subsequence of both? Wait: If a is a subsequence of b, then a is subsequence of a (trivially) and also of b. So a is common, so can't use a. But b might be longer and not subsequence of a. So then answer is len(b). So that's covered.
What if a is a subsequence of b and b is also a subsequence of a? That forces equality.
Thus answer is simply: if a == b then -1 else max(len(a), len(b)). But is there any corner case like a="" or b="" ? Problem says non-empty. So fine.
But wait: Could there be a longer uncommon subsequence than max(len(a), len(b))? No, because any subsequence of a is at most len(a) length, similarly for b. So the maximum possible length of any candidate is max(len(a), len(b)). So if we can achieve that, it's optimal.
Now, is it always possible to achieve max(len(a), len(b)) when strings differ? If the longer string (say b) is not a subsequence of a (which is always true because longer length > len(a) implies cannot be subsequence). So b itself is a valid candidate: b is a subsequence of b, and it is not a subsequence of a because longer. So answer = len(b). So yes.
But what if strings are same length but differ? Then both have length L. Neither is subsequence of the other (since they differ). So both are candidates. So answer L.
Thus trivial solution.
But hold on, the problem might be more subtle: "subsequence of one of them and not a subsequence of the other." That is exactly what we used. So the longest uncommon subsequence is basically the longer string if they are different, else -1. That seems too trivial for a problem that might be from Codeforces (maybe CF 766A). Actually I recall a Codeforces problem: "Mahmoud and Longest Uncommon Subsequence". Yes, problem 766A. The solution is exactly that: if a == b, print -1; else print max(len(a), len(b)). So indeed it's trivial.
But wait, there might be nuance: Could there be a longer uncommon subsequence that is not the whole string but longer than max? Not possible.
Thus answer is straightforward.
Now, the problem statement: "Given two strings a and b, find the length of their longest uncommon subsequence, which is the longest string that is a subsequence of one of them and not a subsequence of the other." That matches.
So algorithm: read two strings, compare equality, output -1 if equal else max length.
Check constraints: up to 1e5 each, so no issue.
But is there any scenario where strings are not equal but the max length string is actually a subsequence of the other? For longer string can't be subsequence of shorter because length. For equal length, if they are different, one cannot be subsequence of the other because they have same length but differ; the only way a string of length L is subsequence of another string of length L is if they are identical (since you need all characters matched, which forces equality). So safe.
Thus answer is trivial.
We can implement.
But wait, there's a nuance: The problem says "longest string that is a subsequence of one of them and not a subsequence of the other." Could there be a string longer than both a and b that is subsequence of one? No because any subsequence cannot be longer than the original string.
Thus indeed.
So final solution: if a == b: print(-1) else: print(max(len(a), len(b))).
Time O(n) for equality (string comparison) but we can just compare directly. However note that string comparison is O(min(len(a), len(b))) which is fine.
Let's double-check the example: a="abcd", b="defgh" -> lengths 4,5, not equal -> output 5. correct.
Edge cases: a="abc", b="abd". lengths equal 3, not equal. So output 3. Is there any uncommon subsequence of length 3? The string "abc" is subsequence of a but not of b? Check if "abc" is subsequence of "abd": a then b then c? "abd" has a,b,d; c missing. So not subsequence. So "abc" qualifies. Similarly "abd" qualifies. So output 3 is valid.
What about a="", b="a"? But input says non-empty, so ignore.
Thus solution accepted.
But wait, there is a more complex scenario: Consider a="aaa", b="aa". Strings not equal, lengths 3 and 2. Output 3. "aaa" is subsequence of a, but is it a subsequence of b? b="aa", cannot have 3 a's. So qualifies. So answer 3.
But is there any uncommon subsequence of length 2? Possibly, but 3 is longer.
Now, consider a="aa", b="aaa". Output 3 similarly.
Thus correct.
Therefore we can code.
But we must ensure we read strings possibly with newline. Use input().strip().
Potential pitfalls: The problem may require to handle large input, but Python's input is fine.
We can also do: a=input().strip(); b=input().strip(); if a==b: print(-1) else: print(max(len(a), len(b))).
Thus answer.
But we should provide reasoning and code.
Now, for completeness, let's prove: Let LUS = longest uncommon subsequence. If a != b, then w.l.o.g. suppose len(a) >= len(b). If a is not a subsequence of b, then a is uncommon (subsequence of a not of b) and length = len(a). If a is a subsequence of b, then since len(a) >= len(b) and a is subsequence of b, we must have len(a) = len(b) and a == b (because a subsequence of same length implies equality). Contradiction because a != b. So a cannot be subsequence of b. Therefore a is uncommon. So answer = len(a). So if lengths differ, longer string is automatically not a subsequence of the other and qualifies. If lengths equal but strings differ, both are not subsequence of each other, so answer = len(a). So overall answer is max(len(a), len(b)) unless a==b, then -1.
Thus solved.
Now, let's consider if there might be tricky test where strings are equal but of different cases? All lowercase.
Thus final answer.
Now produce final output. ```python
def solve() -> None:
import sys
a = sys.stdin.readline().strip()
b = sys.stdin.readline().strip()
if a == b:
print(-1)
else:
print(max(len(a), len(b)))
if name == "main":
solve()