def solution(s, n):
answer = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' * (n + 1)
s = list(s)
for i in range(len(s)):
a = ord(s[i].upper())
if s[i] == ' ':
continue
if s[i] in answer:
s[i] = answer[(a + n) % 65]
else:
s[i] = answer[(a + n) % 65].lower()
return ''.join(s)