#K1426. Minimum Operations to Equalize Two Numbers
Minimum Operations to Equalize Two Numbers
Minimum Operations to Equalize Two Numbers
You are given two non‐negative integers X and Y. Your task is to determine the minimum number of operations required to transform X into Y by performing digit-wise modifications.
In one operation, you may change a single digit of X so that it matches the corresponding digit of Y. If the numbers have different lengths, the extra digits in the longer number must each be handled with an additional operation (either by appending or removing digits).
This can be formally expressed as follows:
$$\text{operations} = \sum_{i=1}^{n} \mathbb{1}(X_i \neq Y_i) + \left|\;|X| - |Y|\right|,$$ where $$n = \min(|X|, |Y|)$$, and \(\mathbb{1}\) is the indicator function that is 1 if the condition is true and 0 otherwise.
Your goal is to compute and output this minimum number of operations.
inputFormat
The input is read from stdin and consists of a single line containing two non-negative integers X and Y separated by a space.
outputFormat
Print to stdout a single integer, representing the minimum number of operations required to transform X into Y.
## sample1234 4321
4