#C3972. Reverse the First N Characters

    ID: 47458 Type: Default 1000ms 256MiB

Reverse the First N Characters

Reverse the First N Characters

Given a string S and an integer N, your task is to reverse the first N characters of S while leaving the rest of the string unchanged. It is guaranteed that \( 1 \le N \le |S| \) where \(|S|\) denotes the length of S.

For example, if S = "helloworld" and N = 5, then the first 5 characters "hello" are reversed to "olleh", resulting in "ollehworld".

You need to read the input from standard input (stdin) and print your answer to standard output (stdout).

inputFormat

The input consists of two lines:

  • The first line contains a string S.
  • The second line contains an integer N representing the number of characters from the beginning of S to be reversed.

outputFormat

Output the resulting string after reversing the first N characters of S. Print the result to stdout.

## sample
helloworld
5
ollehworld