import java.util.*;
class Solution {
public String solution(String s, int n) {
StringBuilder answer = new StringBuilder();
for (int i=0; i<s.length(); i++) {
char x = s.charAt(i);
if (x == ' ') {
answer.append(' ');
continue;
}
if (Character.isLowerCase(x)) { // 소문자인 경우
x = (char) ((x - 'a' + n) % 26 + 'a');
} else { // 대문자인 경우
x = (char) ((x - 'A' + n) % 26 + 'A');
}
answer.append(x);
}
return answer.toString();
}
public static void main(String[] args) {
String s = "a B z";
int n = 4;
Solution sol = new Solution();
String result = sol.solution(s, n);
System.out.print(result); // 출력: "e F d"
}
}