#P3531. Minimum Adjacent Swaps to Transform One String into Another

    ID: 16785 Type: Default 1000ms 256MiB

Minimum Adjacent Swaps to Transform One String into Another

Minimum Adjacent Swaps to Transform One String into Another

Given two strings \(a\) and \(b\) of equal length consisting only of uppercase letters, determine the minimum number of adjacent swaps required to transform \(a\) so that it becomes \(b\). In each move, you may swap two adjacent characters in \(a\).

inputFormat

The input consists of two lines. The first line contains the string \(a\) and the second line contains the string \(b\).

outputFormat

Print a single integer, the minimum number of adjacent swaps needed to transform \(a\) into \(b\).

sample

ABC
ACB
1