cho.sh
Notes
Loading...

String Alignment Score

Time limit

2s

Memory limit

128 MB

Problem

You are given two nonempty strings X and Y consisting of lowercase English letters. You may insert spaces anywhere between characters or at either end of each string. After inserting spaces, the two strings must have the same length, and no position may contain spaces in both strings.

For each aligned position, you earn points as follows.

  1. If the two characters are the same lowercase letter, you earn A points.
  2. If exactly one of the two characters is a space, you earn B points.
  3. If both characters are lowercase letters and they are different, you earn C points.

When A = 10, B = -1, and C = -5, one possible alignment is shown below.

Position1234
Xa(space)bc
Y(space)d(space)c

The scores at the four positions are -1, -1, -1, and 10, so the total score is 7.

Given X and Y, find the maximum total score obtainable by inserting spaces.

Input

The first line contains three integers A, B, and C. They satisfy 0 < A <= 10,000 and -10,000 <= B, C < 0.

The second line contains X, and the third line contains Y. Both strings consist only of lowercase English letters, and each has length between 1 and 3,000 inclusive.

Output

Print the maximum total score.