#include <bits/stdc++.h>
using namespace std;
long long n;
string s;
string f()
{
    string ans;
    for (int i=0; i<s.size(); i++)
    {
        if (s[i]-'a'>'z'-'a' || s[i]-'a'<0 && s[i]-'A'>'Z'-'A' || s[i]-'A'<0)
        {
            ans.push_back(s[i]);
            continue;
        }
        if (s[i]>'a'-1 && s[i]<'z'+1)
        {
            if (n>0)
            {
                if (s[i]-n<'a'-0)
                {
                    ans.push_back('z'-'a'+1+s[i]-n);
                }
                else
                {
                    ans.push_back(s[i]-n);
                }
            }
            else
            {
                if (s[i]-n>'z'+1)
                {
                    ans.push_back('a'-s[i]-n);
                }
                else
                {
                    ans.push_back(s[i]-n);
                }
            }
        }
        if (s[i]>'A'-1 && s[i]<'Z'+1)
        {
            if (n>0)
            {
                if (s[i]-n<'A'-0)
                {
                    ans.push_back('Z'-'A'+1+s[i]-n);
                }
                else
                {
                    ans.push_back(s[i]-n);
                }
            }
            else
            {
                if (s[i]-n>'Z'+1)
                {
                    ans.push_back('A'-s[i]-n);
                }
                else
                {
                    ans.push_back(s[i]-n);
                }
            }
        }
    }
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    getline(cin, s);
    cin>>n;
    cout<<f()<<"\n";
    return 0;
}