Rotation

3.6

96 votes
Algorithms, Brute Force, Easy, String Manipulation, easy
Problem

You are given two strings  and  of the same length . Your task is to convert the string  into  by doing some operations. In an operation, you can delete the first character of the string  and append any character at the end of the string. You are required to determine the minimum number of operations to convert  into .

Input format

  • First line: Single integer  denoting the length of the strings
  • Second line: String 
  • Third line: String 

Output format
Print a single integer that represents the answer to the question.

Constraints

Both strings consist of only lowercase alphabets.

Sample Input
7
aaxaabc
aabcaax
Sample Output
3
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

After the  operation 
After the  operation 
After the  operation 
After  operation  and  becomes same.

Editor Image

?