Algorithm


C. Letters Cyclic Shift
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z 'y 'x 'b 'a 'z'. In other words, each character is replaced with the previous character of English alphabet and 'a' is replaced with 'z'.

What is the lexicographically minimum string that can be obtained from s by performing this shift exactly once?

Input

The only line of the input contains the string s (1 ≤ |s| ≤ 100 000) consisting of lowercase English letters.

Output

Print the lexicographically minimum string that can be obtained from s by shifting letters of exactly one non-empty substring.

Examples
input
Copy
codeforces
output
Copy
bncdenqbdr
input
Copy
abacaba
output
Copy
aaacaba
Note

String s is lexicographically smaller than some other string t of the same length if there exists some 1 ≤ i ≤ |s|, such that s1 = t1, s2 = t2, ..., si - 1 = ti - 1, and si < ti.

 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int const N = 1e5 + 1;
char s[N];

int main() {
	scanf("%s", s);

	int len = strlen(s), idx = -1;
	for(int i = 0; i < len; ++i)
		if(s[i] != 'a') {
			idx = i;
			break;
		}

	if(idx == -1) {
		s[len - 1] = 'z';
		puts(s);
		return 0;
	}

	while(idx < len && s[idx] != 'a') {
		s[idx] = char(int(s[idx]) - 1);
		++idx;
	}
	puts(s);

	return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
codeforces

Output

x
+
cmd
bncdenqbdr
Advertisements

Demonstration


Codeforces Solution-Letters Cyclic Shift-Solution in C, C++, Java, Python

Previous
Codeforces solution 1080-B-B. Margarite and the best present codeforces solution
Next
CodeChef solution DETSCORE - Determine the Score CodeChef solution C,C+