#include<bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    string s, ans;
    getline(cin, s);
    cin>>n;
    n=n*(-1);
    long long ost=abs(n)%26;
    for(int i=0; i<s.size(); i++)
    {
        if((s[i]>='a' && s[i]<='z') || (s[i]>='A' && s[i]<='Z'))
        {
            if(n>=0)
            {
                if(s[i]>='a' && s[i]<='z')
                {
                    if('z'-s[i]>=ost) ans.push_back(s[i]+ost);
                    else
                    {
                        long long f=ost;
                        f-=('z'-s[i]+1);
                        ans.push_back('a'+f);
                    }
                }
                else
                {
                    if('Z'-s[i]>=ost) ans.push_back(s[i]+ost);
                    else
                    {
                        long long f=ost;
                        f-=('Z'-s[i]+1);
                        ans.push_back('A'+f);
                    }
                }
            }
            else
            {
                long long h;
                if(s[i]>='a' && s[i]<='z') h=s[i]-'a';
                else h=s[i]-'A';
                if((h-ost)>=0) ans.push_back(s[i]-ost);
                else
                {
                    int a=ost;
                    a-=(h+1);
                    if(s[i]>='a' && s[i]<='z') ans.push_back('z'-a);
                    else ans.push_back('Z'-a);
                }
            }
        }
        else ans.push_back(s[i]);
    }
    cout<<ans;
    return 0;
}
