using System;
using System.Linq;

namespace A.cAPS_lOCK
{
    class Submit
    {
        static bool AllCapital(string input)
        {
            return input.All(each => char.IsUpper(each));
        }
        static string Capitalize(string input)
        {
            if (AllCapital(input)) { return input.ToLower(); }
            else if (char.IsLower(input[0]) && AllCapital(input.Substring(1))) { return string.Format("{0}{1}", char.ToUpper(input[0]), input.Substring(1).ToLower()); }
            else { return input; }
        }

        static void Main(string[] args)
        {
            Console.Write(Capitalize(Console.ReadLine()));
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _2_1
{
    class Program
    {
        static void Main(string[] args)
        {
            string Str = Console.ReadLine();
            char[] Ch = Str.ToCharArray();
            short Count = 0;
            if (Char.IsUpper(Ch[0]))
            {
                for (int i = 1; i < Ch.Length; i++)
                    if (Char.IsUpper(Ch[i])) Count++;
                if (Ch.Length - 1 == Count)
                {
                    Upper(Ch);
                    Console.WriteLine(Ch);
                   // Console.ReadKey();
                    return;
                }
            }

            if (Char.IsLower(Ch[0]))
            {
                for (int i = 1; i < Ch.Length; i++)
                {
                    if (Char.IsUpper(Ch[i])) Count++;
                }
                if (Count == Ch.Length - 1)
                {
                    Low(Ch);
                    Console.WriteLine(Ch);
                    //Console.ReadKey();
                    return;
                }
                else
                {
                    Console.WriteLine(Ch);
                   // Console.ReadKey();
                }
            }
            else
            {
                Console.WriteLine(Ch);
               // Console.ReadKey();
            }
        }

        static char[] Upper (char[] Ch)
        {
            for (int i = 0; i < Ch.Length; i++)
               Ch[i] = Char.ToLower(Ch[i]);
            return Ch;
        }

        static char[] Low (char[] Ch)
        {
            Ch[0] = Char.ToUpper(Ch[0]);
            for (int i = 1; i < Ch.Length; i++)
               Ch[i] = Char.ToLower(Ch[i]);
            return Ch;
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Globalization;
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            bool p=false; bool p1=false;
            if (char.ToLower(Convert.ToChar(s[0]))==s[0] ) p1=true;
            for (int i=0;i<s.Length;i++)
            {

                if (char.ToUpper(Convert.ToChar(s[i]))==s[i]) {p=true;}
                else
                {
                    p=false;
                    if (i!=0) {p1 =false;
                    break;}
                }
            }
            if (p1 || p)
            {
             char[] ar = new char[s.Length];
             string s1="";
             for (int i=0;i<s.Length;i++)
              {
                  ar[i]=Convert.ToChar(s[i]);
                  if (char.ToUpper(ar[i])==ar[i]) s1=s1+char.ToLower(ar[i]);

                  if (char.ToLower(ar[i])==ar[i])s1=s1+char.ToUpper(ar[i]);
              }
              Console.WriteLine(s1);
            }
            else
           Console.WriteLine(s);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication16
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            char c = s.First();
            string s2 = s.ToUpper();
            char c2 = s2.First();
            s2=s2.Remove(0, 1);
            string s3 = s.ToLower();
            char c3 = s3.First();
            s3 = s3.Remove(0, 1);

            int a=0, b = 0;

            for (int i = 1; i < s.Length; i++)
            {
                if (c >= 65 && c <= 90 && s[i] >= 65 && s[i] <= 90)
                {
                    a++;
                }
                if (c >= 97 && c <= 122 && s[i] >= 65 && s[i] <= 90)
                {
                    b++;
                }
            }
            if (s.Length == 1)
            {
                if (c <= 122 && c >= 97) Console.WriteLine(c2);
                else Console.WriteLine(c3);
            }
            else if (a == s.Length - 1) Console.WriteLine(c3 + s3);
            else if (b == s.Length - 1) Console.WriteLine(c2 + s3.ToLower());
            else Console.WriteLine(s);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CAPSLOCK
{
    class Program
    {
        static void Main(string[] args)
        {
            var Word = Console.ReadLine();
            var Upper = 0;

            foreach (var item in Word)
            {
                if (char.IsUpper(item))
                    Upper++;
            }
            if (Upper == Word.Length )
            {
                var Lower = Word.ToLower();
                Console.WriteLine(Lower);
            }
            else if (char.IsLower(Word[0]) && Upper == Word.Length - 1)
            {
                var Lower = char.ToUpper(Word[0]) + Word.Substring(1).ToLower();
                Console.WriteLine(Lower);
            }
            else
                Console.WriteLine(Word);
        }

    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace ConsoleApp5
{
    public class Program
    {
        //var t = int.Parse(Console.ReadLine());
        //var arr = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        static void Main()
        {
            var str = Console.ReadLine();
            var res = str;

            if (Regex.IsMatch(str, "^[A-Z][A-Z]*$"))
                res = str.ToLower();
            else if (Regex.IsMatch(str, "^[a-z][A-Z]*$"))
                res = str[0].ToString().ToUpper() + (str.Length > 1 ? str.Substring(1).ToLower() : "");

            Console.WriteLine(res);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace W0lf
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine(), r = s[0].ToString().ToUpper(), str = s;
            if(s.ToUpper() == s)
                str = s.ToLower();
            else if(s.Remove(0, 1).ToUpper() == s.Remove(0, 1))
                str = s.ToLower().Remove(0, 1).Insert(0, r);
            Console.WriteLine(str);
            Console.ReadLine();
        }
    }
}

using System;
using System.Linq;
using System.Collections.Generic;
using System.Globalization;

namespace A._cAPS_lOCK
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            List<char> list = new List<char>(input);
            bool case1 = false;
            bool case2 = false;
            for (int i = 0; i < list.Count(); i++)
            {
                if (i == 0)
                {
                    if (list[i] >= 'a' && list[i] <= 'z')
                    {
                        case1 = true;
                    }
                    else
                    {
                        case2 = true;
                    }
                }
                else if (list[i] >= 'a' && list[i] <= 'z')
                {
                    case1 = false;
                    case2 = false;
                }
            }
            for (int i = 0; i < list.Count(); i++)
            {

                if (case1 == true)
                {
                    if (i == 0)
                    {
                        list[0] = char.ToUpper(list[0]);
                    }
                    else
                    {
                        list[i] = char.ToLower(list[i]);
                    }
                }
                else if (case2 == true)
                {
                    list[i] = char.ToLower(list[i]);
                }
            }
            foreach (var el in list)
            {
                Console.Write(el);
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Code_Forces
{
    class Program
    {

        static void Main(string[] args)
        {

            string s = Console.ReadLine();
            int count = 0;
            char[] arr = s.ToCharArray();

            for (int i = 0; i < s.Length; i++)
            {
                if (arr[i] == char.ToUpper(arr[i]))
                    count++;
            }
           /*
            if (arr[0] == char.ToLower(arr[0]) && count == 0)
            {
                Console.WriteLine(char.ToUpper(arr[0]));
            }
            */
            if (s.Length == 1)
            { if (arr[0]==char.ToLower(arr[0]))
                Console.WriteLine(s.ToUpper());
            else

                Console.WriteLine(s.ToLower());
            }
            else if (arr[0] == char.ToLower(arr[0]) && count == s.Length - 1)
            {
                for (int i = 1; i < s.Length; i++)
                {
                    arr[0] = char.ToUpper(arr[0]);
                    arr[i] = char.ToLower(arr[i]);

                }
                Console.WriteLine(arr);
            }

            else if (s == s.ToUpper())
            {
                Console.WriteLine(s.ToLower());
            }

            else
                Console.WriteLine(s);

        }
    }
}

using System;

namespace A131
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            bool mayus = true;

            foreach (char letter in input.Substring(1))
            {
                if (char.IsLower(letter))
                    mayus = false;
            }

            Console.WriteLine(mayus && char.IsLower(input[0]) ?
                (char.ToUpper(input[0]) + input.Substring(1).ToLower()) : (char.IsUpper(input[0]) && mayus ?
                input.ToLower() : input));
        }
    }
}

using System;

namespace CF_131A
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();

            char[] ch = input.ToCharArray();

            if(ch[0] >= 97 && ch.Length == 1)
            {
                Console.WriteLine((char)(ch[0] - 32));
            }
            else if(ch[0] >= 97 && ch.Length > 1)
            {
                int count = 0;

                for (int i = 1; i < ch.Length; i++)
                {
                    if (ch[i] >= 65 && ch[i] <= 90)
                    {
                        count++;
                    }
                }

                if(count == ch.Length - 1)
                {
                    ch[0] = (char)(ch[0] - 32);
                    for (int i = 1; i < ch.Length; i++)
                    {
                        ch[i] = (char)(ch[i] + 32);
                    }
                    Console.WriteLine(ch);
                }
                else
                {
                    Console.WriteLine(ch);
                }
            }
            else if(ch[0] >= 65 && ch[0] <= 90 && ch.Length > 1)
            {
                int count = 0;

                for (int i = 1; i < ch.Length; i++)
                {
                    if (ch[i] >= 65 && ch[i] <= 90)
                    {
                        count++;
                    }
                }

                if (count == ch.Length - 1)
                {
                    ch[0] = (char)(ch[0] + 32);
                    for (int i = 1; i < ch.Length; i++)
                    {
                        ch[i] = (char)(ch[i] + 32);
                    }
                    Console.WriteLine(ch);
                }
                else
                {
                    Console.WriteLine(ch);
                }
            }
            else
            {
                Console.WriteLine((char)(ch[0] + 32));
            }
        }
    }
}

using System;
using System.Linq;

namespace _131A
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            char[] chrs = str.ToCharArray();
            if (chrs.Length > 1 && chrs.Skip(1).All(char.IsUpper) || chrs.Length == 1)
            {
                str = new string(chrs.Select(ch => char.IsUpper(ch) ? char.ToLower(ch) : char.ToUpper(ch)).ToArray());
            }
            Console.WriteLine(str);
        }
    }
}

using System;

namespace dev
{
    class Program
    {
        static void Main(string[] args)
        {
            string word = Console.ReadLine();

            char[] checkWordArray = new char[word.Length - 1];
            word.CopyTo(1, checkWordArray, 0, word.Length - 1);
            string checkWord = new string(checkWordArray);

            char[] newWord = new char[word.Length];

            if ((Char.IsLower(word[0]) && checkWord == checkWord.ToUpper()) || word == word.ToUpper())
            {
                for (int i = 0; i < word.Length; i++)
                {
                    if (Char.IsUpper(word[i]))
                    {
                        newWord[i] = Char.ToLower(word[i]);
                    }
                    else
                    {
                        newWord[i] = Char.ToUpper(word[i]);
                    }
                }
                Console.WriteLine(newWord);
            }
            else
            {
                Console.WriteLine(word);
            }

        }
    }
}

using System;

namespace _131A
{
    class Program
    {
        static void Reverse(string txt)
        {
            for(int i = 0; i < txt.Length; i++)
            {
                if (char.IsLower(txt[i])) //если буква строчная, то
                {
                    Console.Write(char.ToUpper(txt[i]));
                }
                else //или же
                {
                    Console.Write(char.ToLower(txt[i]));
                }
            }
        }
        static void Main(string[] args)
        {
            string txt = Console.ReadLine();
            if(txt.Length > 1)
            {
                if (txt.ToUpper() == txt) //если вся строка в прописных буквах
                {
                    Reverse(txt);
                }
                else
                {
                    if (char.IsLower(txt[0]) && char.IsUpper(txt[1]) && txt.TrimStart(txt[0]) == txt.TrimStart(txt[0]).ToUpper()) //если первая буква строчная, а вторая прописная и в оставшейся части нет строчных букв
                    {
                        Reverse(txt);
                    }
                    else
                    {
                        Console.Write(txt); //если всё в исходном положении, то
                    }
                }
            }
            else
            {
                Reverse(txt);
            }
        }
    }
}

using System;
using System.Linq;
using System.Text;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            string word = Console.ReadLine();
            bool uppercase = true;

            for (int i = 1; i < word.Length; i++)
            {
                if (word[i] >= 'a')
                    uppercase = false;
            }

            if (uppercase == true)
            {
                for (int i = 0; i < word.Length; i++)
                {
                    if (word[i] >= 'a')
                        Console.Write(word[i].ToString().ToUpper());
                    else
                        Console.Write(word[i].ToString().ToLower());
                }
            }
            else
                Console.WriteLine(word);

            Console.ReadLine();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AscII_Code
{
    class Program
    {
        static void Main(string[] args)
        {
            string name = Console.ReadLine();
            bool capslock = true;
            char[] array = name.ToCharArray();
            for (int i = 1; i < array.Length; i++)
            {
                /* input the small letter */
                char c = array[i];
                if (c >= 'a' && c <= 'z')
                {
                    capslock = false;
                }
            }
            if (capslock)
            {

                for (int i = 0; i < array.Length; i++)
                {

                    char c = array[i];
                    if (c >= 'a' && c <= 'z')
                    {
                        array[i] = (char)((int)c - 32);

                    }
                    if (c >= 'A' && c <= 'Z')
                    {
                        array[i] = (char)((int)c + 32);

                    }

                }
            }
            for (int i = 0; i < array.Length; i++)
            {
                Console.Write(array[i]);
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _131A_CapsLock
{
    static class Program
    {
        public static bool IsAllUppercase(this string str, int start)
        {
            int i = 0;
            for (i = start; i < str.Length; i++)
            {
                if (str[i] >= 'a' && str[i] <= 'z') return false;
            }
            return true;
        }

        static void PrintAllLowercase(this string str, int start)
        {
            int i = 0;
            char ch;
            for (i = start; i < str.Length; i++)
            {
                Console.Write(char.ToLower(str[i]));
            }
            Console.Write("\n");
        }
        static void Main(string[] args)
        {
            int i = 0;
            string str = Console.ReadLine();
            char ch;

            if (str.Length==1)
            {
                if (str[0] >= 'a' && str[0] <= 'z')
                {
                    ch = char.ToUpper(str[0]);
                    Console.WriteLine(ch);
                }
                else
                {
                    ch = char.ToLower(str[0]);
                    Console.WriteLine(ch);
                }

            }

            else if (str.IsAllUppercase(0))
            {
                str.PrintAllLowercase(0);
            }

            else if (str[0] >= 'a' && str[0] <= 'z' && str.IsAllUppercase(1))
            {
                ch = char.ToUpper(str[0]);
                Console.Write(ch);
                str.PrintAllLowercase(1);
            }
            else
            {
                Console.WriteLine(str);
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication12
{
    class Program
    {
        static void Main(string[] args)
        {
            string data = Console.ReadLine();

            //条件としては、全部大文字 OR 最初小文字で以降大文字のときに、変換すればいい
            bool flg = false;

            //もし先頭小文字なら
            if (char.IsLower(data[0]))
            {
                if (data.Length == 1)
                {
                    Console.WriteLine(data.ToUpper());
                    return;
                }
                bool caps = true;
                //もし後ろの文字列がすべて小文字なら反転する
                for (int i = 1; i < data.Length; i++)
                {
                    if (!char.IsLower(data[i]))
                        caps = false;
                }
                if (caps)
                {
                    Console.WriteLine(data);
                    return;
                }
                //ではなく，ごちゃ混ぜだったらそのまま表示
                for (int i = 1; i < data.Length; i++)
                {
                    if (!char.IsUpper(data[i]))
                        caps = true;
                }
                if (caps)
                {
                    Console.WriteLine(data);
                    return;
                }
                else
                {
                    Console.Write(char.ToUpper(data[0]));

                    for (int j = 1; j < data.Length; j++)
                    {
                        Console.Write(char.ToLower(data[j]));
                    }
                    return;
                }
            }

            //もし大文字なら
            if (char.IsUpper(data[0]))
            {
                if (data.Length == 1)
                {
                    Console.WriteLine(data.ToLower());
                    return;
                }

                //後ろがすべて大文字ならひっ繰り返して表示
                bool caps = true;
                for (int i = 0; i < data.Length; i++)
                {
                    if (!char.IsUpper(data[i]))
                        caps = false;
                }
                if (caps)
                {
                    Console.WriteLine(data.ToLower());
                    return;
                }

                //そうじゃなくて，ごちゃまぜだったらそのまま表示
                Console.WriteLine(data);
                //for (int i = 1; i < data.Length; i++)
                //{
                //    if (!char.IsLower(data[i]))
                //        caps = true;
                //}
                //if (caps)
                //{
                //    Console.WriteLine(data);
                //    return;
                //}
                //else
                //{
                //    Console.Write(char.ToLower(data[0]));

                //    for (int j = 1; j < data.Length; j++)
                //    {
                //        Console.Write(char.ToUpper(data[j]));
                //    }
                //    return;
                //}
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace cAPS_lOCK
{
    class Program
    {
        static public void problem()
        {
            string x = Console.ReadLine();

            if (x.ToUpper() == x)
            {
                string k = x.ToLower();
                Console.WriteLine(k);
            }
            else if (x.Substring(1).ToUpper()==x.Substring(1))
            {
                string k = x.Substring(1).ToLower();
                Console.WriteLine(char.ToUpper(x[0])+k);
            }
            else
            {
                Console.WriteLine(x);
            }

        }
        static void Main(string[] args)
        {
            problem();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication12
{
    class Capslock
    {
        static void Main(string[] args)
        {
            Capslock.Run();
        }

        static void Run()
        {
            string data = Console.ReadLine();

            if (Judge(data))
                Reversal(data);

            Console.WriteLine((Judge(data)) ? Reversal(data) : data);
        }

        /// <summary>
        /// 判定関数
        /// </summary>
        /// <returns>反転する場合はtrue</returns>
        static bool Judge(string input)
        {
            for (int i = 1; i < input.Length; i++)
            {
                if (char.IsLower(input[i]))
                    return false;
            }
            return true;
        }

        /// <summary>
        /// 反転関数
        /// </summary>
        /// <param name="input">反転する対象の文字列</param>
        /// <returns>反転した結果を返します</returns>
        static string Reversal(string input)
        {
            string temp = "";
            for (int i = 0; i < input.Length; i++)
            {
                if (char.IsLower(input[i]))
                    temp += char.ToUpper(input[i]);
                else
                    temp += char.ToLower(input[i]);
            }

            return temp;
        }
    }
}

using System;
class Test
{
    static void Main()
    {
        string sTmp = Console.ReadLine();
        string [] aTmp = sTmp.Split();
        string ans = "";

        for (int i = 0 ; i<aTmp.Length ; i++){
            int L,U,S;
            L = U = S = 0;
            int k = 0;
            foreach(char c in aTmp[i]){
                if(Char.IsUpper(c)){
                    U++;
                }
                if(Char.IsLower(c)){
                    L++;
                }
                k++;
            }
            S = U+L;
            if(U == S){
                int j = 0 ;
                foreach(char v in aTmp[i]){
                    if( j == 0){
                        aTmp[i] = "";
                    }
                    aTmp[i] += Char.ToLower(v);
                    j++;
                }
            }
             else if(L == 1 && Char.IsLower(aTmp[i][0])){
                int j = 0 ;
                foreach(char v in aTmp[i]){
                    if( j == 0){
                        aTmp[i] = "";
                        aTmp[i] += Char.ToUpper(v);
                    } else {
                        aTmp[i] += Char.ToLower(v);
                    }
                    j++;
                }
            }
        }
        for(int l = 0 ; l<aTmp.Length ; l++){
            if(l != aTmp.Length-1){
                ans += aTmp[l]+" ";
            } else {
                 ans += aTmp[l];
            }
        }

        Console.WriteLine(ans);
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace rg
{
    class Program
    {
        static string[] GetArray()
        {
            return Console.ReadLine().Split(' ');
        }
        static void Main(string[] args)
        {
            int i,j;
            char s;
            string n;
            n = Console.ReadLine();
            int[] a = new int[n.Length];
            for(i=0;i<n.Length;i++)
            {
                a[i] = (int)n[i];
                /*if(n[0]>96)
                {
                    if (n[i] > 96) break;
                    else if(n[i]<97)
                    {

                        n[i] =n[i]-32;
                    }
                }*/
            }
            for(i=1;i<n.Length;i++)
            {
                if(a[0]>96) //avali koochak
                {
                    if (a[i] > 96) break;
                    else if(a[i]>64 && a[i]<91)
                    {
                        for(j=i+1;j<n.Length;j++)
                        {
                            if (a[j] > 96) break;
                        }
                        if(j==n.Length) //do be bad bozorg
                        {
                            for(j=i;j<n.Length;j++)
                            {
                                a[j] += 32;
                            }
                            a[0] -= 32;
                        }

                    }
                }

                else if (a[0] < 91) //avali bozorg
                {
                    if (a[i] > 96) break;
                    else if (a[i] < 91)
                    {
                        for (j = i + 1; j < n.Length; j++)
                        {
                            if (a[j] > 96) break;
                        }
                        if (j == n.Length) //do be bad koochak
                        {
                            for (j = i; j < n.Length; j++)
                            {
                                a[j] += 32;
                            }
                            a[0] += 32;
                        }
                    }
                }
            }
            if (n.Length == 1)
            {
                if (a[0] > 96) a[0] -= 32;
                else if (a[0] < 91 && a[0] > 64) a[0] += 32;
            }
            /*for(i=0;i<n.Length;i++)
            {
                Convert.ToInt32(n[i]);
                n[i] = a[i];
            }*/
            for(i=0;i<n.Length;i++)
            {
                s = (char)a[i];
                Console.Write(s);
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _131A
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            string output = string.Empty;
            bool flag = true, bflag;
            if (str.Length != 0)
            {
                output = str[0].ToString().ToUpper();
            }
            for (int i = 1; i < str.Length; i++)
            {
                if (i == 1)
                {
                    if (str[i] >= 'a' && str[i] <= 'z')
                    {
                        flag = false;
                    }
                    else
                    {
                        flag = true;
                    }
                    output += (str[i].ToString()).ToLower();
                }
                else
                {
                    if (str[i] >= 'a' && str[i] <= 'z')
                    {
                        bflag = false;
                    }
                    else
                    {
                        bflag = true;
                    }
                    if (flag == bflag)
                    {
                        output += (str[i].ToString()).ToLower();
                    }
                    else
                    {
                        Console.WriteLine(str);
                        return;
                    }
                }
            }
            if (str.Length != 0)
            {
                if (str[0] >= 'A' && str[0] <= 'Z' && flag == true)
                {
                    Console.WriteLine(str.ToLower());
                    return;
                }
                if (str[0] >= 'a' && str[0] <= 'z' && flag == false)
                {
                    Console.WriteLine(str);
                    return;
                }
            }
            Console.WriteLine(output);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static string make(string s)
        {
            string w = "";
            if (char.IsLower(s[0]) && char.IsUpper(s[1])) {
                w += char.ToUpper(s[0]);
            }
            if (w.Length != 0)
            {
                for (int i = 1; i < s.Length; i++)
                {
                    if (char.IsUpper(s[i]))
                    {
                        w += char.ToLower(s[i]);
                    }
                    else
                    {
                        w += char.ToUpper(s[i]);
                    }
                }
                return w;
            }
            else
            {
                return s;
            }
        }
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            if (s.Length == 1)
            {
                if (char.IsUpper(s[0]))
                {
                    Console.WriteLine(s.ToLower());
                }
                else
                {
                    Console.WriteLine(s.ToUpper());
                }
                return;
            }
            bool can = true;
            for (int i = 1; i < s.Length; i++)
            {
                if (char.IsLower(s[i]))
                {
                    can = false;
                    break;
                }
            }
            if ((can && char.IsUpper(s[0])))
            {
                Console.WriteLine(s.ToLower());
                return;
            }
            if ((can && char.IsLower(s[0])))
            {
                Console.WriteLine(make(s));
            }
            else
            {
                Console.WriteLine(s);
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _131A
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = "";

            str = Console.ReadLine();
            bool flag = false;
            for (int i = 1; i < str.Length; i++)
            {
                if (str[i].ToString() != str[i].ToString().ToUpper())
                {
                    flag = true;
                    break;
                }
            }
            if (flag)
            {
                Console.Write(str);
            }
            else
            {
                if (str[0].ToString() == str[0].ToString().ToUpper())
                {
                    Console.Write(str.ToLower());
                }
                else
                {
                    Console.Write(str[0].ToString().ToUpper() + str.Substring(1).ToLower());
                }
            }
            Console.ReadLine();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ejercicios
{
    class Program
    {
        static string funcion (string str)
        {
            string newStr = "", first;

            if (str.Length == 1 && isLower(str[0]))
                return str.ToUpper();

            if (str.Length == 1 && isUpper(str[0]))
                return str.ToLower();

            if (isUpper(str[0])){
                if (rest(str))
                    return str.ToLower();
                else
                    return str;
            }
            else
            {
                if (rest(str))
                {
                    first = str[0].ToString().ToUpper();
                    newStr = str.Substring(1);
                    newStr = first + newStr.ToLower();
                    return newStr;
                }
                else
                {
                    return str;
                }

            }
        }

        static bool rest (string str){
            for (int i = 1; i < str.Length; i++)
            {
                if (isLower(str[i]))
                    return false;
            }
            return true;
        }

        static bool isUpper(char letter)
        {
            string alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            for (int i = 0; i < alpha.Length; i++)
            {
                if (letter == alpha[i])
                return true;
            }
            return false;
        }

        static bool isLower(char letter)
        {
            string alpha = "abcdefghijklmnopqrstuvwxyz";
            for (int i = 0; i < alpha.Length; i++)
            {
                if (letter == alpha[i])
                    return true;
            }
            return false;
        }

        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            Console.WriteLine(funcion(str));
        }
    }
}

using System;
using System.Text;
using System.Linq;

namespace Test
{

    class Program
    {
        static void Main(string[] args)
        {
            string word = Console.ReadLine();

            // Case 1
            if (word.Length == 1)
            {
                if (char.IsUpper(word[0]))
                    Console.WriteLine(word.ToLower());
                else
                    Console.WriteLine(word.ToUpper());
                return;
            }

            // Case 2
            if (word.All(char.IsUpper))
            {
                Console.WriteLine(word.ToLower());
                return;
            }
            else if(word.All(char.IsLower))
            {
                Console.WriteLine(word.ToLower());
                return;
            }

            int numOfChange = 0;
            bool flag;
            if (char.IsUpper(word[0]))
                flag = true;
            else
                flag = false;

            for (int i = 1; i < word.Length; i++)
            {
                if (char.IsUpper(word[i]) != flag)
                {
                    flag = !flag;
                    numOfChange++;
                }

                if (numOfChange == 2)
                {
                    Console.WriteLine(word);
                    return;
                }
            }

            if(numOfChange == 1)
            {
                if(char.IsLower(word[0])&& !char.IsLower(word[1]))
                {
                    StringBuilder _word = new StringBuilder();
                    for (int i = 0; i < word.Length; i++)
                    {
                        if (char.IsLower(word[i]))
                            _word.Append(char.ToUpper(word[i]));
                        else
                            _word.Append(char.ToLower(word[i]));
                    }
                    Console.WriteLine(_word);
                    return;
                }
                else
                {
                    Console.WriteLine(word);
                    return;
                }
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace cAPSlOCK
{
    class Program
    {
        static void Main(string[] args)
        {
            string word = Console.ReadLine();
            StringBuilder uncapped = new StringBuilder();
            bool isCapped = true;

            uncapped.Append(Char.ToUpper(word[0]));
            for (int i = 1; i < word.Length; i++)
            {
                uncapped.Append(Char.ToLower(word[i]));
                if (!Char.IsUpper(word[i]))
                {
                    isCapped = false;
                }
            }
            if (isCapped && Char.IsUpper(word[0]))
            {
                uncapped[0] = Char.ToLower(word[0]);
            }

            Console.WriteLine("{0}", isCapped ? uncapped.ToString() : word);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _5
{
    class Program
    {
        static void Main(string[] args)
        {
            string n = Console.ReadLine();
            char[] c = n.ToCharArray();

            bool v = true;

            for (int i = 1; i < c.Length; i++)
            {
                if (c[i].CompareTo('a') < 0)
                {
                    continue;
                }
                else
                {

                    v = false;
                    break;
                }
            }
            if (v == true)
            {

                for (int j = 0; j < c.Length; j++)
                {
                    if (c[j].CompareTo('a') < 0)
                    {
                        char a = char.ToLower(c[j]);
                        c[j] = a;
                        continue;
                    }
                    if (c[j].CompareTo('a') >= 0)
                    {
                        char a = char.ToUpper(c[j]);
                        c[j] = a;
                    }
                }
                c.ToString();
                Console.WriteLine(c);
            }
            else
            {
                c.ToString();
                Console.WriteLine(c);
            }

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace c95a1
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine();

            int i=0,j=0;
            for (i = 0; i < a.Length; i++)
            {
                if (char.IsUpper(a[i]))
                {
                    continue;
                }
                else
                {
                    break;
                }
            }

            if (i == a.Length)
            {
                a = a.ToLower();
                Console.WriteLine(a);
                return;
            }

            if (char.IsLower(a[0]))
            {
                for (j = 1; j < a.Length; j++)
                {
                    if (char.IsUpper(a[j]))
                    {
                        continue;
                    }
                    else
                    {
                        break;
                    }
                }
            }

            if (j == a.Length)
            {
                string s = a[0].ToString().ToUpper();
                a = a.ToLower();
                StringBuilder sb = new StringBuilder(a);
                sb[0] = Convert.ToChar(s);
                a = sb.ToString();
                Console.WriteLine(a);
                return;
            }
            Console.WriteLine(a);
        }

    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Training
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var l = s.Length;
            var c = false;
            int co = 0;
            for (var i = 0; i < l; i++)
            {
                var u = char.IsUpper(s[i]);
                if (i == 0)
                {
                    c = u;
                }
                else
                {
                    if (u)
                    {
                        co++;
                    }
                    else
                    {
                        Console.WriteLine(s);
                        return;
                    }
                }
            }

            if (c)
            {
                Console.WriteLine(s.ToLower());
            }
            else
            {
                var r = s.First().ToString().ToUpper() + s.Substring(1).ToLower();
                Console.WriteLine(r);
            }
        }
    }
}

using System;
using System.Linq;
using System.Text.RegularExpressions;

class Problem15A{
	static void Main(string[] args){
		Regex reg = new Regex("[A-Z]");
		String word = Console.ReadLine();
		if((char.ToLower(word[0]) == word[0] && reg.Replace(word, "").Length == 1)){
			Console.Write(char.ToUpper(word[0])+word.Substring(1, word.Length-1).ToLower());
		}else if(reg.Replace(word, "").Length == 0){
			Console.Write(word.ToLower());
		} else Console.Write(word);
	}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        public static void Main()
        {
            var str = Console.ReadLine();
            if (str.Length == 1)
                if ((int)str[0] > 96 && (int)str[0] < 123)
                    Console.WriteLine(str.ToUpper());
                else Console.WriteLine(str.ToLower());
            else
            {
                bool firstLetterIsBig = false;
                if ((int)str[0] > 64 && (int)str[0] < 91)
                    firstLetterIsBig = true;
                bool allLettersIsBig = true;
                for (var i = 1; i < str.Length; i++)
                {
                    if ((int)str[i] > 96 && (int)str[i] < 123)
                    {
                        allLettersIsBig = false;
                        break;
                    }
                }
                if (allLettersIsBig)
                {
                    if (firstLetterIsBig)
                        Console.WriteLine(str.ToLower());
                    else
                    {
                        str = str.ToLower();
                        string result = str[0].ToString().ToUpper() + str.Substring(1, str.Length - 1);
                        Console.WriteLine(result);
                    }
                }
                else
                    Console.WriteLine(str);
            }
        }
    }
}

using System;
class Caps
{
		static void Main()
		{
				string input = Console.ReadLine();
				string comp = input.ToLower();
				int count = 0;
				for(int i = 0; i < input.Length; i++)
				{
						if(input[i] == comp[i])
							count++;
				}
				if(count==0)
						Console.WriteLine(comp);
				else if(count==1 && input[0]==comp[0])
				{
					string result = "";
					for(int i = 0; i < input.Length; i++)
					{
							string tmp = comp[i].ToString();
							if(i==0)
							result+=tmp.ToUpper();
							else
							result+=tmp;
					}
					Console.WriteLine(result);
				}
				else
					Console.WriteLine(input);
		}
}

using System;

namespace CF_Caps {
    class Program {
        static void Main(string[] args) {
            string input = Console.ReadLine();
            char firstletter = input[0];
            if (Char.IsUpper(input[0])) {
                firstletter = Char.ToLower(input[0]);
            } else {
                firstletter = Char.ToUpper(input[0]);
            }
            string output = input.Remove(0, 1);
            int size = output.Length;
            int uppercount = 0;
            for(int i = 0; i < size; ++i) {
                if (Char.IsUpper(output[i])) {
                    uppercount++;
                }
            }
            if(uppercount == output.Length) {
                output = output.ToLower();
                Console.WriteLine(firstletter + output);
                return;
            }
            Console.WriteLine(input);
        }
    }
}

using System;

namespace ProblemSolvingPrepation
{
    class Program
    {
        static void Main(string[] args)
        {
            String InputWord;
            InputWord = Console.ReadLine();
            bool b1 = IsCaps(InputWord);
            bool b2 = isFirstLetterNotCaps(InputWord);
            if (b1 || b2)
            {

                for(int i = 0; i < InputWord.Length; i++)
                {
                    if(char.IsUpper(InputWord[i]))
                     Console.Write(char.ToLower(InputWord[i]));
                    else
                        Console.Write(char.ToUpper(InputWord[i]));
                }
            }
            else
                Console.WriteLine(InputWord);
        }
        public static bool IsCaps(string inputWord)
        {
            foreach (char c in inputWord)
            {
                if (!char.IsUpper(c))
                    return false;

            }
            return true;
        }
        public static bool isFirstLetterNotCaps(string inputWord)
        {
            if (char.IsUpper(inputWord[0]))
                return false;
            for(int i = 1; i < inputWord.Length; i++)
            {
                if (char.IsLower(inputWord[i]))
                    return false;
            }
            return true;
        }
    }
}

using System;

namespace CF_Caps {
    class Program {
        static void Main(string[] args) {
            string input = Console.ReadLine();
            char firstletter = input[0];
            if (Char.IsUpper(input[0])) {
                firstletter = Char.ToLower(input[0]);
            } else {
                firstletter = Char.ToUpper(input[0]);
            }
            string output = input.Remove(0, 1);
            int uppercount = 0;
            for(int i = 0; i < output.Length; ++i) {
                if (Char.IsUpper(output[i])) {
                    uppercount++;
                }
            }
            if(uppercount == output.Length) {
                output = output.ToLower();
                Console.WriteLine(firstletter + output);
                return;
            }
            Console.WriteLine(input);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Olymp_dop
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            for (int i = 1; i < s.Length; i++)
            {
                if (!(s[i] >= 'A' && s[i] <= 'Z'))
                {
                    Console.WriteLine(s);
                    return;
                }
            }
            if (s[0]>='a' && s[0] <= 'z')
            {
                Console.WriteLine(s[0].ToString().ToUpper() + s.Substring(1, s.Length - 1).ToLower());
                return;
            }
            Console.WriteLine(s[0].ToString().ToLower() + s.Substring(1, s.Length - 1).ToLower());
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            if (s == s.ToUpper())
            {
                Console.WriteLine(s.ToLower());
            }
            else
            if ((s.Substring(1, s.Length - 1) == s.Substring(1,s.Length-1).ToUpper()) &&
                (s[0].ToString() == s[0].ToString().ToLower()))
            {
                Console.Write(s[0].ToString().ToUpper()+ s.Substring(1, s.Length - 1).ToLower());
            }
            else
                Console.WriteLine(s);
            Console.ReadLine();
        }
    }
}

using System;

namespace capslock
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string str = Console.ReadLine();
            char ch;

            if (str.Length > 1)
            {
                for (int i = 1; i < str.Length; i++)
                {
                    ch = str[i];
                    if (ch >= 'a' && ch <= 'z')
                    {
                        Console.WriteLine(str);
                        return;
                    }
                }
            }

            string result = "";
            foreach (char character in str)
            {
                result += switchcase(character);
            }
            Console.WriteLine(result);
        }

        public static char switchcase(char ch)
        {
            if (ch >= 'a' && ch <= 'z')
                return (char)(ch - 32);
            if (ch >= 'A' && ch <= 'Z')
                return (char)(ch + 32);
            return ch;
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C1CapsLock
{
    class Program
    {
        static void Main(string[] args)
        {
            string usrInput = Console.ReadLine();

            if (case1(usrInput))
                Console.WriteLine(usrInput.ToLower());
            else if (case2(usrInput))
                 Console.WriteLine(usrInput.Substring(0, 1).ToUpper()+usrInput.Substring(1).ToLower());
            else
                Console.WriteLine(usrInput);
            Console.ReadLine();
        }
        static bool case1(string str)
        {
            for (int i = 0; i < str.Length; i++)
            {
                if (!char.IsUpper(str[i]))
                    return false;
            }
            return true;
        }
        static bool case2(string str2)
        {
            return case1(str2.Substring(1)) && char.IsLower(str2[0]);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    public class Program
    {
        public static void Main(String[] args )
        {

            var str = Console.ReadLine();
            string str2 = str.Substring(1).ToUpper();
            if (str.Substring(1) == str2)
            {
                if (str.First().ToString() == str.First().ToString().ToUpper())
                {
                    Console.WriteLine(str.ToLower());
                }
                else
                {
                    Console.WriteLine(str.First().ToString().ToUpper() + str.Substring(1).ToLower());
                }
            }

            else
            {

                Console.WriteLine(str);
            }

        }
    }

}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A.cAPS_lOCK
{
    class Program
    {
        static void Main(string[] args)
        {
            string word = Console.ReadLine();
            string alphacap = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            char[] m = alphacap.ToCharArray();
            string small = "abcdefghijklmnopqrstuvwxyz";
            int sum = 0;
            int sum2=0;
            int j = 0;
            string l = "";
            for (int i = 0; i < word.Length; i++)
            {
                for ( j = 0; j < alphacap.Length; j++)
                {
                    if (word[i] == alphacap[j] )
                    {
                        sum++;
                    }
                }
            }
            j = 0;
            for (j = 0; j < alphacap.Length; j++)
            {
                if (word[0] == small[j])
                {
                    sum2++;
                    l = alphacap[j].ToString();
                    break;
                }
            }
            if (sum == word.Length)
            {
                word = word.ToLower();
                Console.WriteLine(word);
            }
            else if (sum2 == 1 && sum == word.Length - 1)
            {
                word = word.ToLower();
                word = word.Remove(0, 1);
                word = word.Insert(0, l);
                Console.WriteLine(word);
            }
            else
                Console.WriteLine(word);

        }
    }
}

using System;

namespace _36__A._cAPS_lOCK
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();

            if (input.Length==1 && (int)input[0] >= 97 && (int)input[0] <= 122)
            {
                Console.WriteLine(input.ToUpper());
            }

            else if (input.Length == 1 && (int)input[0] >= 65 && (int)input[0] <= 90)
            {
                Console.WriteLine(input.ToLower());
            }

            else
            {

                int counter = 0;

                for (int i = 0; i < input.Length; i++)
                {
                    if ((int)input[i] >= 65 && (int)input[i] <= 90)
                    {
                        counter++;

                    }

                }

                int counter2 = 0;

                if ((int)input[0] >= 97 && (int)input[0] <= 122)
                {
                    for (int i = 1; i < input.Length; i++)
                    {
                        if ((int)input[i] >= 65 && (int)input[i] <= 90)
                        {
                            counter2++;

                        }

                    }

                }

                if (counter2 == (input.Length - 1))
                {
                    char[] array = input.ToLower().ToCharArray();

                    int b = (int)array[0] - 32;

                    char gh = (char)b;
                    array[0] = gh;

                    Console.WriteLine(array);

                }
                else if (counter == input.Length)
                {

                    Console.WriteLine(input.ToLower());

                }

                else
                {

                    Console.WriteLine(input);
                }

            }
        }
    }

}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _10_CapsLock_131A
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();

            char[] letters = line.ToCharArray();
            char first;
            bool wrong = false;
            string output = "";
            if (letters.Length > 1)
            {
                if (char.IsUpper(letters[0]) && char.IsUpper(letters[1]))
                {
                    for (int i = 2; i < line.Length; i++)
                    {
                        if (!char.IsUpper(line[i]))
                        {
                            wrong = true;
                            break;
                        }
                    }
                    if (!wrong)
                        output = line.ToLower();
                    else
                        output = line;
                }
                else if (char.IsLower(letters[0]) && char.IsUpper(letters[1]))
                {
                    for (int i = 2; i < line.Length; i++)
                    {
                        if (!char.IsUpper(line[i]))
                        {
                            wrong = true;
                            break;
                        }
                    }
                    if (!wrong)
                    {
                        first = line[0];
                        first = char.ToUpper(first);
                        string tail = line.Substring(1).ToLower();
                        output += first;
                        output += tail;
                    }
                    else
                    {
                        output = line;
                    }
                }
                else
                {
                    output = line;
                }
            }
            else
            {
                if (char.IsLower(letters[0]))
                    output = line.ToUpper();
                else
                    output = line.ToLower();
            }
            /*
            for (int i = 0; i < letters.Length; i++)
            {
                first = letters[i];
                if (i == 0)
                {
                    if (char.IsLower(letters[i]))
                       turnAround = true;
                }
                else if (i == 1)
                {
                    if (turnAround)
                    {
                        if (!char.IsUpper(letters[i]))
                            break;
                        else
                        {
                            char.ToUpper(first);
                            char.ToLower(letters[i]);
                            output += first + letters[i];
                        }
                    }
                    else
                    {
                        if (!char.IsUpper(letters[i]))
                            break;
                        else
                        {
                            char.ToLower(first);
                            char.ToLower(letters[i]);
                            output += first + letters[i];
                        }
                    }
                }
                else
                {
                    char.ToLower(letters[i]);
                    output += letters[i];
                }
            }*/
            Console.WriteLine(output);
            Console.ReadLine();

        }
    }
}

using System;

class Program
{
    static void Main(string[] args)
    {
        string input = Console.ReadLine();
        bool capOn = true;

        if (input.Length == 1)
        {
            if (input[0] <= 'Z')
            {
                Console.WriteLine(input.ToLower());
                return;
            }
        }

        for (int i = 1; i < input.Length; i++)
        {
            if (!(input[i] <= 'Z'))
            {
                capOn = false;
            }
        }

        if (capOn)
        {
            foreach (var c in input)
            {
                if (c <= 'Z')
                {
                    Console.Write((char)(c+32));
                }
                else
                {
                    Console.Write((char)(c-32));
                }
            }
            System.Console.WriteLine();
        }
        else
        {
            System.Console.WriteLine(input);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;

public static class cAPS_lOCK
{
    private static void Solve()
    {
        string str = Read();

        if (str.All(char.IsUpper))
            Write(str.ToLower());
        else if (char.IsLower(str[0]) && str.Skip(1).All(char.IsUpper))
            Write(str[0].ToString().ToUpper() + str.Substring(1).ToLower());
        else
            Write(str);
    }

    #region Main

    private static TextReader reader;
    private static TextWriter writer;
    public static void Main()
    {
#if DEBUG
        //reader = new StreamReader("C:\\Users\\Axel\\Desktop\\input.txt");
        reader = new StreamReader(Console.OpenStandardInput());
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("input.txt");
        //writer = new StreamWriter("output.txt");
#endif
        try
        {
            Solve();
            //var thread = new Thread(new cAPS_lOCK().Solve, 1024 * 1024 * 128);
            //thread.Start();
            //thread.Join();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
#if DEBUG
#else
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); }
    public static string Read() { while (currentLineTokens.Count == 0) currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }
    public static int ReadInt() { return int.Parse(Read()); }
    public static long ReadLong() { return long.Parse(Read()); }
    public static double ReadDouble() { return double.Parse(Read(), CultureInfo.InvariantCulture); }
    public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }
    public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }
    public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }
    public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++) matrix[i] = ReadIntArray(); return matrix; }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++) ret[i][j] = matrix[j][i]; }
        return ret;
    }
    public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++) lines[i] = reader.ReadLine().Trim(); return lines; }
    public static void WriteArray<T>(IEnumerable<T> array) { writer.WriteLine(string.Join(" ", array)); }
    public static void Write(params object[] array) { WriteArray(array); }
    public static void WriteLines<T>(IEnumerable<T> array) { foreach (var a in array) writer.WriteLine(a); }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++) ret[i] = new T(); return ret; }
    #endregion
}

using System;

namespace ConsoleApplication6
{
    class Program
    {
        static bool IsWrongCaps(ref string s)
        {
            if (s[0] >= 'A' && s[0] <= 'Z')
            {
                for (int i = 1; i < s.Length; i++)
                    if (s[i] >= 'a' && s[i] <= 'z') return false;
                s = s.ToLower();
            }
            else
            {
                for (int j = 1; j < s.Length; j++)
                    if (s[j] >= 'a' && s[j] <= 'z') return false;
                s = s[0].ToString().ToUpper() + s.Remove(0, 1).ToLower();
            }
            return true;
        }
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            if (IsWrongCaps(ref input))
            {
                Console.Write(input);
            }
            else
            Console.Write(input);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace cAPSLOCK___codeforces
{
    class Program
    {
        static void Main(string[] args)
        {

            string s = Console.ReadLine().ToString();
            string result = string.Empty;

            for (int i = 0; i < s.Length; i++)
            {
                if (char.IsLower(s[0]) && i == 0)
                {
                    result = char.ToUpper(s[0]).ToString();
                }

                else if (char.IsUpper(s[i]))
                {
                    result = result + char.ToLower(s[i]).ToString();
                }
                else
                {
                    result = string.Empty;
                    result = s;
                    break;
                }
            }

          Console.WriteLine(result);

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace codeforces
{
    class Program
    {
        public static void check(string i)
        {
            string temp1 = i.ElementAt(0).ToString();
            string temp2 = i.Substring(1);
            string temp3 =i.Substring(1);
            temp2 = temp2.ToUpper();
            temp1 = temp1.ToUpper();

            if (temp1 == i.ElementAt(0).ToString()&&temp2==temp3)
            {
                string arr;
                arr = i.Substring(1);
                if (i.Substring(1) == arr)
                {
                    arr = arr.ToLower();
                    string temp4 = i.ElementAt(0).ToString();
                    temp4 = temp4.ToLower();
                    Console.WriteLine(temp4 + arr);
                    return;
                }

                    Console.WriteLine(i);

            }
            else{

                if (i.Substring(1)==temp2)
                {
                    i = i.ToUpper();
                    string arr;
                    arr = i.Substring(1);

                    arr = arr.ToLower();

                    i = i.ElementAt(0) + arr;
                    Console.WriteLine(i);
                }
                else
                {
                Console.WriteLine(i);
                }

            }
        }
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            check(input);

        }
    }
}

 using System;
    using System.Collections.Generic;
    using System.Globalization;
    using System.Linq;
    using System.Text;
    public class Program
    {
        public static void Main(string[] args)
        {
            var str = Console.ReadLine();
            var sb = new StringBuilder(str);
            var firstCase = true;
            var secondCase = true;

            if ((char)sb[0] >= 97 && (char)sb[0] <= 122)
            {
                for (int i = 1; i < str.Length; i++)
                {
                    if ((char)sb[i] >= 65 && (char)sb[i] <= 90)
                    {
                        firstCase = true;
                    }
                    else
                    {
                        firstCase = false;
                        break;
                    }
                }
                if (firstCase)
                {
                    str = str.ToUpper();
                    sb[0] = str[0];
                    str = str.ToLower();
                    for (int i = 1; i < str.Length; i++)
                    {
                        sb[i] = str[i];
                    }
                    str = sb.ToString();
                }

            }
            else
            {
                for (int i = 0; i < str.Length; i++)
                {
                    if ((char)sb[i] >= 65 && (char)sb[i] <= 90)
                    {
                        secondCase = true;
                    }
                    else
                    {
                        secondCase = false;
                        break;
                    }
                }
                if (secondCase)
                {
                    str = str.ToLower();
                }
            }

            Console.WriteLine(str);
        }
    }

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {

            string h = Console.ReadLine();
            if(h.ToArray().Count(x=>x.ToString().ToUpper()==x.ToString()) == h.Length)
            {
                Console.WriteLine(h.ToLower());
            }
            else if(h.ToArray().Count(x => x.ToString().ToUpper() == x.ToString()) + 1 == h.Length && h[0].ToString().ToUpper() != h[0].ToString()) //same
            {
                Console.WriteLine(h[0].ToString().ToUpper() + h.Substring(1).ToLower());
            }
            else if(h[0].ToString().ToUpper() != h[0].ToString() && h.Length == 1) //same
            {
                Console.WriteLine(h[0].ToString().ToUpper() + h.Substring(1).ToLower());
            }
            else
            {
                Console.WriteLine(h);
            }
            Console.ReadLine();

        }
    }
}

using System;

namespace CapsLock
{
    internal class Program
    {
        private static void Main()
        {
            var line = Console.ReadLine().Trim();
            var length = line.Length;

            if (length == 1)
            {
                if (line[0] < 97 || line[0] > 122)
                {
                    Console.WriteLine(line.ToLower());
                }
                else
                {
                    Console.WriteLine(line.ToUpper());
                }
            }
            else if (AllUpper(line, length))
            {
                line = line.ToLower();
                Console.WriteLine(line);
            }
            else if (JustFirstLower(line, length))
            {
                line = line.ToLower();
                line = line[0].ToString().ToUpper() + line.Substring(1);
                Console.WriteLine(line);
            }
            else
            {
                Console.WriteLine(line);
            }
        }

        private static bool JustFirstLower(string line, int length)
        {
            if (line[0] < 97 || line[0] > 122)
            {
                return false;
            }

            for (var i = 1; i < length; i++)
            {
                if (line[i] < 65 || line[i] > 90)
                {
                    return false;
                }
            }

            return true;
        }

        private static bool AllUpper(string line, int length)
        {
            for (var i = 0; i < length; i++)
            {
                if (line[i] < 65 || line[i] > 90)
                {
                    return false;
                }
            }

            return true;
        }
    }
}

using System;
using System.Text;

namespace cAPS_LOCK
{
	using string2 = StringBuilder;
	class MainClass
	{
		public static void Main (string[] args)
		{
			string2 s = new string2( Console.ReadLine () );
			string2 s2 = new string2(s.ToString());

			bool kt = true;
			for (int i = 1; i < s.Length; ++i)
				if (s [i] >= 'A' && s [i] <= 'Z') {
					s [i] = (char)(s [i] + 32);
				} else {
					kt = false;
					break;
				}
			if (!kt)
				Console.Write (s2);
			else {
				if (s [0] >= 'a' && s [0] <= 'z')
					s [0] = (char)(s [0] - 32);
				else if (s [0] >= 'A' && s [0] <= 'Z')
					s [0] = (char)(s [0] + 32);
				Console.Write (s);
			}
			Console.ReadLine ();
		}
	}
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Test
{
    class Program
    {
        class OlimpiadTaskC
        {
            static void Main(string[] args)
            {
                string line = Console.ReadLine();
                bool lower = false;
                for (int i = 1; i < line.Length; i++)
                {
                    if (char.IsLower(line[i]))
                    {
                        lower = true;
                        break;
                    }
                }
                if(char.IsLower(line[0]) && !lower)
                {
                    line = line.ToLower();
                    line = line.Substring(0, 1).ToUpper() + line.Remove(0, 1);
                    Console.WriteLine(line);
                    return;
                }
                if (!char.IsLower(line[0]) && !lower)
                {
                    line = line.ToLower();
                    Console.WriteLine(line);
                    return;
                }
                Console.WriteLine(line);
            }
        }
    }
}

using System;
using System.Linq;
using System.Text.RegularExpressions;

namespace Codeforces
{
  class Program
  {
    static void Main(string[] args)
    {
      var word = Console.ReadLine();

      if(Regex.IsMatch(word, "^[a-z]{1}[A-Z]+$"))
      {
        word = Char.ToUpper(word[0]) + word.Substring(1).ToLower();
      }

      else if (Regex.IsMatch(word, "^[^a-z]+$"))
      {
        word = word.ToLower();
      }

      else if (Regex.IsMatch(word, "^[a-z]{1}$"))
      {
        word = word.ToUpper();
      }

      Console.WriteLine(word);
    }
  }
}

using System;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine(); bool o = false, a = true;
            if (s[0].ToString().ToUpper() != s[0].ToString())
                a = false;
            for (int i = 1; i < s.Length; i++)
            {
                if (s[i].ToString().ToUpper() != s[i].ToString())
                { o = true; a = true; break; }
            }

            if (o == a && a == true)
                Console.WriteLine(s);
            else if (a)
                Console.WriteLine(s.ToLower());
            else Console.WriteLine(s[0].ToString().ToUpper() + s.Substring(1).ToLower());
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().ToList();
            bool f=true;
            for (int i = 1; i < s.Count; i++)
            {
                if (!Char.IsUpper(s[i])) f = false;
            }
            if (f)
            {
                for (int i = 0; i < s.Count; i++)
                {
                    if (Char.IsUpper(s[i]))
                    {
                        Console.Write(Char.ToLower(s[i]));
                    }
                    else
                    {
                        Console.Write(Char.ToUpper(s[i]));
                    }
                }
            }
            else
            {
                for (int i = 0; i < s.Count; i++)
                {
                    Console.Write(s[i]);
                }
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace codeForcesRu_
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(s(Console.ReadLine()));
        }

        static string s(string s)
        {
            if (s.Length == 1)
            {
                if (s == s.ToLower())
                {
                    return s.ToUpper();
                }

                return s.ToLower();
            }

            for (int i = 1; i < s.Length; i++)
            {
                if (!(s[i] >= 'A' && s[i] <= 'Z'))
                {
                    return s;
                }
            }

            var sb = new StringBuilder(s);

            for (int i = 0; i < sb.Length; i++)
            {
                if (sb[i] == char.ToLower(sb[i]))
                {
                    sb[i] = char.ToUpper(sb[i]);
                }
                else
                {
                    sb[i] = char.ToLower(sb[i]);
                }
            }

            return sb.ToString();
        }
    }
}

using System;
using System.Linq;

namespace Application
{
    class Program
    {
        static void Main(string[] args)
        {
            string inp = Console.ReadLine();

	        Console.WriteLine(inp.Length == 1 ? Method(inp[0]) : Method(inp));
        }

        public static string Method(string s)
        {
        	if(s.All(c => char.IsUpper(c))) return s.ToLower();

        	else if(char.IsLower(s[0]) && s.Skip(1).All(c => char.IsUpper(c))) return s.Substring(0,1).ToUpper() + s.Substring(1).ToLower();

        	else return s;

        }

        public static string Method(char ch)
        {
        	string tmp = ch.ToString();

        	return char.IsUpper(tmp[0]) ? tmp.ToLower() : tmp.ToUpper();
        }
    }
}

using System;
using System.Linq;
using System.Text;
using System.Collections;
using System.Collections.Generic;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string l = Console.ReadLine();
            List<char> b = l.ToList<char>();
            int count = b.FindAll(x => char.IsUpper(x)).Count;
            if (char.IsUpper(b[0]))
                count--;
            if(l.Length - count <= 1)
            {
                if (char.IsLower(l[0]))
                    l = char.ToUpper(l[0]) + l.Remove(0, 1);
                else
                    l = char.ToLower(l[0]) + l.Remove(0, 1);
                for (int i = 1; i < l.Length; i++)
                {
                    string a = char.ToLower(l[i]).ToString();
                    l = l.Remove(i, 1);
                    l = l.Insert(i, a);
                }
            }
            Console.WriteLine(l);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {

            string word;
            word = Console.ReadLine();

            if (IsAllUpper(word))
            {
                Console.WriteLine(  word.ToLower());
            }

            else if (System.Char.IsLower(char.Parse(word.Substring(0, 1)))&& IsAllUpper(word.Substring(1,word.Length-1)))
            {

                    Console.WriteLine(word.Substring(0, 1).ToUpper() + word.Substring(1, word.Length - 1).ToLower());

            }

            else if (word.Length == 1)
            {
                Console.WriteLine(word.ToUpper());
            }

            else
            {
                Console.WriteLine(word);
            }

            Console.ReadLine();
        }
       static bool IsAllUpper(string input)
        {
            for (int i = 0; i < input.Length; i++)
            {
                if (!Char.IsUpper(input[i]))
                    return false;
            }
            return true;
        }

       static bool IsAllLOWER(string input)
       {
           for (int i = 0; i < input.Length; i++)
           {
               if (Char.IsUpper(input[i]))
                   return false;
           }
           return true;
       }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;

namespace BulkaProga
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            if (line.Count(x => char.IsUpper(x)) == line.Length || (line.Count(x => char.IsUpper(x)) == line.Length - 1 && char.IsLower(line[0])))
            {
                foreach (char c in line)
                {
                    Console.Write(char.IsLower(c) ? c.ToString().ToUpper() : c.ToString().ToLower());
                }
                Console.Write("\n");
            }
            else
            {
                Console.WriteLine(line);
            }
        }
    }
}

using System;

namespace z1
{
    class Program
    {
        static void Main(string[] args)
        {
            var data = Console.ReadLine(); var data2 = "";
           if(data==data.ToUpper()){ data2 += data.ToLower();}else if (data.Remove(0, 1) == data.Remove(0, 1).ToUpper())
            {
                data2 = data[0].ToString().ToUpper();
                data = data.Remove(0, 1);
                data2 += data.ToLower();

            }
            else
            {
                data2 += data;
            }
            Console.WriteLine(data2);

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{

    class Program
    {
        static int getCountOfUpperCaseChars(string input)
        {
            int count = 0;
            for (int i = 0; i < input.Length; i++)
            {
                if (char.IsUpper(input[i]))
                {
                    count++;
                }

            }
            return count;

        }

        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            var builder = new StringBuilder();

            int totalLength = s.Length;
            int upperCaseCount = getCountOfUpperCaseChars(s);

            bool conditionAllCapital;
            if (totalLength == upperCaseCount)
            {

                conditionAllCapital = true;
            }
            else
            {
                conditionAllCapital = false;
            }

            bool conditionAllCapitalExceptFirst;

            if (Char.IsLower(s[0]) && upperCaseCount == totalLength - 1)
            {

                conditionAllCapitalExceptFirst = true;
            }
            else
            {
                conditionAllCapitalExceptFirst = false;
            }

            if (conditionAllCapital == true || conditionAllCapitalExceptFirst == true)
            {
                for (int i = 0; i < s.Length; i++)
                {

                    if (char.IsLower(s[i]))
                    {
                        char newword = char.ToUpper(s[i]);
                        builder.Append(newword);
                    }

                    if (char.IsUpper(s[i]))
                    {
                        char newword = char.ToLower(s[i]);
                        builder.Append(newword);
                    }
                }
            }
            else
            {
                builder.Append(s);
            }
            Console.Write(builder);

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void swap<T>(ref T a, ref T b)
        {
            T c = a;
            a = b;
            b = c;
        }
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            bool flag = true;
            if (str.Length > 1)
                for (int i = 1; i < str.Length; i++)
                {
                    if (Char.IsLower(str[i]))
                    {
                        flag = !flag;
                        break;
                    }
                }
            if (flag)
            {
                for (int i = 0; i < str.Length; i++)
                {
                    if (Char.IsLower(str[i]))
                        Console.Write(Char.ToUpper(str[i]));
                    else
                        Console.Write(Char.ToLower(str[i]));
                }
            }

            else
                Console.WriteLine(str);
            //System.Console.ReadKey();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication15
{
    class Program
    {
        static void Main(string[] args)
        {
            char []ch = Console.ReadLine().ToCharArray();
            int k=0;
            for (int i = 0; i < ch.Length; i++)
              {
              if(Char.IsUpper(ch[i]))
                  k++;
              }
            if (k == ch.Length)
              {
                  for (int i = 0; i < ch.Length; i++)
                  {
                      ch[i] = Char.ToLower(ch[i]);
                  }
              }
        if ( Char.IsLower(ch[0])&&k==ch.Length-1)
        {
            ch[0] = Char.ToUpper(ch[0]);
            for (int i = 1; i < ch.Length; i++)
            {
                ch[i] = Char.ToLower(ch[i]);
            }
        }

            Console.WriteLine(ch);
            Console.ReadLine();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

namespace cAPSLOCK
{
    class Program
    {
        static void Main(string[] args)
        {
            string res = Console.ReadLine();
            string abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            int temp = res.Substring(1, res.Length - 1).Select(x => x).Where(x => abc.Contains(x.ToString())).Count();
            if (res.Length - temp == 1)
            {
                if (abc.Contains(res[0].ToString()))
                    Console.WriteLine(res.ToLower());
                else
                    Console.WriteLine(res.ToLower().Insert(0, res[0].ToString().ToUpper()).Remove(1, 1));
            }
            else
                Console.WriteLine(res);
            Console.ReadLine();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DZ_1._1
{
    class Program
    {
        static void Main(string[] args)
        {
            #region 282А
            //int x = 0;
            //int timesToCount;
            //timesToCount =  Convert.ToInt32(Console.ReadLine());

            //string[] XCOMmands = new string[timesToCount];

            //for (int i = 0; i < timesToCount; i++)
            //{
            //    XCOMmands[i] = Console.ReadLine();
            //    XCOMmands[i] = XCOMmands[i].ToLower();
            //    if (XCOMmands[i] == "x++" || XCOMmands[i] == "++x") x++;
            //    else if (XCOMmands[i] == "x--" || XCOMmands[i] == "--x") x--;
            //}

            //Console.WriteLine(x);
            ////Console.ReadKey();
            #endregion

            #region 112A
            //int answer = 0;

            //string firstString = Console.ReadLine();
            //string secondString = Console.ReadLine();

            //firstString = firstString.ToLower();
            //secondString = secondString.ToLower();

            //byte[] encodeFirstString = Encoding.ASCII.GetBytes(firstString);
            //byte[] encodeSecondString = Encoding.ASCII.GetBytes(secondString);

            //for (int i=0; i<firstString.Length; i++)
            //{
            //    if (encodeFirstString[i] > encodeSecondString[i])
            //    {
            //        answer = 1;
            //        break;
            //    }
            //    else if (encodeFirstString[i] < encodeSecondString[i])
            //    {
            //        answer = -1;
            //        break;
            //    }
            //}
            //Console.WriteLine(answer);
            ////Console.ReadKey();
            ///
            #endregion

            #region 116A
            //int spaciousness = 0;
            //int passengers = 0;
            //int timesToCount = Convert.ToInt32(Console.ReadLine());
            //for (int i = 0; i < timesToCount; i++)
            //{
            //    string temp = Console.ReadLine();
            //    string[] IOnumbers = temp.Split(' ');
            //    passengers-= Convert.ToInt32(IOnumbers[0]);
            //    passengers+= Convert.ToInt32(IOnumbers[1]);

            //    if (passengers > spaciousness) spaciousness = passengers;
            //}

            //Console.WriteLine(spaciousness);
            ////Console.ReadKey();
            #endregion

            #region 133A
            //string inputText = Console.ReadLine();

            //if (inputText.Contains("H") || inputText.Contains("Q") || inputText.Contains("9")) Console.WriteLine("YES");
            //else Console.WriteLine("NO");

            ////Console.ReadKey();
            #endregion

            #region 131A
            string inputText = Console.ReadLine();
            string substring = inputText.Substring(1, inputText.Length - 1);
            string answer = "";

            bool mistake = false;

            if (substring == substring.ToUpper()) mistake = true;

            if (mistake)
            {
                for (int i = 0; i < inputText.Length; i++)
                {
                    if (char.IsLower(inputText[i])) answer += char.ToUpper(inputText[i]);
                    if (char.IsUpper(inputText[i])) answer += char.ToLower(inputText[i]);
                }
            }
            else answer = inputText;

            Console.WriteLine(answer);
            //Console.ReadKey();
            #endregion

            #region 110A
            //string inputNumber = Console.ReadLine();
            //int luckyCount = 0;
            //for (int i=0;i<inputNumber.Length; i++)
            //{
            //    if (inputNumber[i] == '4' || inputNumber[i] == '7') luckyCount++;
            //}
            //if (luckyCount == 4 || luckyCount == 7) Console.WriteLine("YES");
            //else Console.WriteLine("NO");
            ////Console.ReadKey();
            #endregion
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace codeforces
{
    class cAPS_lOCK
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine(),c="";
            bool depan = false;
            if (char.IsLower(a[0]))
            {
                depan = true;
            }
            bool sisa = false;
            for(int i = 1; i < a.Length; i++)
            {
                if (char.IsLower(a[i]))
                {
                    sisa = true;
                    break;
                }
            }
            if(!depan && !sisa)
            {
                Console.WriteLine(a.ToLower());
            }
            else if(depan && !sisa)
            {
                c += a[0].ToString().ToUpper();
                for(int i = 1; i < a.Length; i++)
                {
                    c += a[i].ToString().ToLower();
                }
                Console.WriteLine(c);
            }
            else
            {
                Console.WriteLine(a);
            }
            //Console.ReadKey();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Probador_de_Codigo
{
    class Program
    {
        static void Main(string[] args)
        {
            string entrada = Console.ReadLine();
            string mayuscula = entrada.ToUpper();
            if(entrada == mayuscula)
                Console.WriteLine(entrada.ToLower());
            else
                if(entrada.Substring(1, entrada.Length - 1) == mayuscula.Substring(1, mayuscula.Length - 1))
                    Console.WriteLine(entrada[0].ToString().ToUpper() + entrada.ToLower().Substring(1, entrada.Length - 1));
                else
                    Console.WriteLine(entrada);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string inp = Console.ReadLine().ToString();
            if (inp.Length == 0)
            {
                Console.WriteLine("");
            }
            int Counter = 0;
            for (int i = 1; i < inp.Length; i++)
            {
                if (Char.IsUpper(inp[i]))
                    Counter++;

            }

                if (Counter == inp.Length - 1)
                {
                    string ans = "";
                    if (Char.IsLower(inp[0]))
                    {

                        ans += Char.ToUpper(inp[0]);
                    }
                    else
                        ans += Char.ToLower(inp[0]);

                    for (int i = 1; i < inp.Length; i++)
                    {
                        ans += Char.ToLower(inp[i]);

                    }
                    Console.WriteLine(ans);
                }
                else
                {
                    Console.WriteLine(inp);
                }

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication28
{
    class Program
    {
        static void Main(string[] args)
        {

            string str = Console.ReadLine();
            string str1 = "";
            if(str.Length>1)
                str1 = str.Substring(1, str.Length-1);

            if (char.IsLower(str.First()) && str.Length == 1 || char.IsLower(str.First()) && !str1.Any(char.IsLower))
            {
                str1 = str1.ToLower();
                Console.WriteLine(char.ToUpper(str[0]) + str1);

            }
            else if (!str.Any(char.IsLower))
            {
                str = str.ToLower();
                Console.WriteLine(str);

            }
            else
                Console.WriteLine(str);

        }
    }
}

using System;

namespace A._cAPS_lOCK
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();

            if (line.Length == 0) Console.WriteLine(line.ToUpper());
            else if ((int)line[0] >= 97 && isAllUpper(line.Substring(1)))
            {
                Console.Write((char)(line[0] - 32));
                foreach (char c in line.Substring(1))
                {
                    Console.Write((char)(c + 32));
                }
            }
            else if (isAllUpper(line))
            {
                foreach (char c in line)
                {
                    Console.Write((char)(c + 32));
                }
            }
            else
            {
                Console.WriteLine(line);
            }
        }

        static bool isAllUpper(string line)
        {
            foreach (int c in line)
            {
                if (c >= 97) return false;
            }
            return true;
        }
    }
}

using System;

namespace CodeForce
{
    class _131A_CapsLock
    {
        static void Main()
        {
            string input = Console.ReadLine();

            // 첫번째가 대문자
            if(input[0] >= 'A' && input[0] <= 'Z')
            {
                // 이후 소문자가 나오면 그대로 출력
                for(int i = 1; i < input.Length; i++)
                {
                    if (input[i] >= 'a' && input[i] <= 'z')
                    {
                        Console.WriteLine(input);
                        return;
                    }
                }
                // 모두 대문자일경우
                Console.WriteLine(input.ToLower());
            }
            // 첫번째가 소문자
            else
            {
                // 이후 소문자가 나오면 그대로 출력
                for (int i = 1; i < input.Length; i++)
                {
                    if (input[i] >= 'a' && input[i] <= 'z')
                    {
                        Console.WriteLine(input);
                        return;
                    }
                }
                // 모두 대문자일경우
                Console.WriteLine("{0}{1}", Char.ToUpper(input[0]), input.Remove(0, 1).ToLower());
            }
        }
    }
}

using System;
using System.Collections.Generic;

namespace test {
    class Class1 {

        public static void Main() {
            string s = Console.ReadLine();
            int i = 1, j = s.Length;
            for (; i < j; i++) {
                if(s[i] >= 'a'){
                    Console.WriteLine(s);
                    return;
                }
            }
            j = 1;
            if(s[0] < 'a')
                Console.Write(  (char)(s[0] + 32) );
            else
                Console.Write(  (char)(s[0] - 32) );
            for (; j < i; j++) {
                Console.Write((char)(s[j] + 32));
            }
        }
    }
}

using System;
using System.Text;
using System.Collections.Generic;
class Problem
{
    static void Main()
    {
        string str = Console.ReadLine();
        for(int i=1;i<str.Length;i++)
            if(str[i] > 'Z')
            {
                Console.WriteLine( str );
                return;
            }
        if(str[0] >= 'A'&&str[0]<='Z')
            Console.WriteLine( str.ToLower() );
        if(str[0] <= 'z'&&str[0]>='a')
            Console.WriteLine( str[0].ToString().ToUpper() + str.Substring( 1, str.Length - 1 ).ToLower() );
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test {
    class Class1 {
        static int change(char c) {
            if (c >= 'A' && c <= 'Z')
                return c - 'A' + 'a';
            if (c >= 'a' && c <= 'z')
                return c - 'a' + 'A';
            return c;
        }

        public static void Main() {
            string s = Console.ReadLine();
            bool flag = true;
            for (int i = 1; flag && i < s.Length; i++) {
                flag = s[i] < 'a';
            }
            if (!flag)
                Console.WriteLine(s);
            else
                for (int i = 0; i < s.Length; i++) {
                    Console.Write((char)(change(s[i])));
                }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Training_Linklist_post_pre_infix
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            char CH_1 = str[0];
            string more = "";
            for (int f = 1; f < str.Length; f++)
                more += str[f].ToString();

            string more_LOW = more.ToLower(), more_UP = more.ToUpper();
            //=================================================
            if (str.Length == 1)
            {
                if(str==str.ToUpper())
                Console.Write(str.ToLower());
                if (str == str.ToLower())
                    Console.Write(str.ToUpper());
            }
            else
            {
                if (str == str.ToUpper() || (str == str.ToLower()))
                    Console.Write(str.ToLower());
                else if (CH_1.ToString() == CH_1.ToString().ToUpper())// && ((more == more_LOW) || (more == more_UP)))//first U other L || U
                    Console.Write(str);
                else if ((CH_1.ToString() == CH_1.ToString().ToLower()) && ((more != more_LOW) && (more != more_UP)))
                    Console.Write(str);
                else
                {
                    CH_1 = char.Parse(CH_1.ToString().ToUpper());
                    str = str.ToLower();
                    Console.Write(CH_1.ToString());
                    for (int i = 1; i < str.Length; i++)
                        Console.Write(str[i]);
                }
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace add
{
    class Program
    {
        static void Main(string[] args)
        {
            string a=Console.ReadLine();
            string b=a.Substring(0,1);
            string c=a.Substring(1,a.Length-1);
            string d=c.ToUpper();
            if(c==d)
            {
            string e=b.ToUpper();
            if(e==b)
            {
                Console.WriteLine(b.ToLower()+d.ToLower());
            }
            else
            {
                Console.WriteLine(b.ToUpper()+d.ToLower());
            }

            }
            else
            {
            Console.WriteLine(a);
            }
        }
}
}

using System;
using System.Collections.Generic;

namespace test {
    class Class1 {

        public static void Main() {
            int i = 1, j = 1;
            string s = Console.ReadLine();
            for (; i < s.Length; i++) {
                if(s[i] >= 'a'){
                    Console.WriteLine(s);
                    return;
                }
            }
            Console.Write( s[0] < 'a' ? (char)(s[0] + 32) : (char)(s[0]  -  32));
            for (; j < i; j++) {
                Console.Write((char)(s[j] + 32));
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace task131A
{
    class Program
    {
        static string Answer(string str)
        {
            Dictionary<char, char> d1 = new Dictionary<char, char>();
            string temp = str.ToLower();
            for (char i = 'a'; i <= 'z'; i++)
            {
                d1.Add(i, (char)((int)i - 32));
            }
            short k = 0;
            Int32 index = -1;
            for (Int32 i = 0; i < str.Length; i++)
            {
                if (d1.ContainsKey(str[i]))
                {
                    k++;
                    index = i;
                }
            }
            if (k > 1) return str;
            if (index > 0) return str;
            if (index == -1) return temp;
            return d1[temp[0]] + temp.Substring(1);
        }
        static void Main(string[] args)
        {
            string temp = Console.ReadLine();
            Console.WriteLine(Answer(temp));
            //Console.ReadLine();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _131A_CapsLock
{
    static class Program
    {
        public static bool IsAllUppercase(this string str, int start)
        {
            int i = 0;
            for (i = start; i < str.Length; i++)
            {
                if (str[i] >= 'a' && str[i] <= 'z') return false;
            }
            return true;
        }

        static void PrintAllLowercase(this string str, int start)
        {
            int i = 0;
            char ch;
            for (i = start; i < str.Length; i++)
            {
                Console.Write(char.ToLower(str[i]));
            }
            Console.Write("\n");
        }
        static void Main(string[] args)
        {
            int i = 0;
            string str = Console.ReadLine();
            char ch;

            if (str.Length==1)
            {
                if (str[0] >= 'a' && str[0] <= 'z')
                {
                    ch = char.ToUpper(str[0]);
                    Console.WriteLine(ch);
                }
                else
                {
                    Console.WriteLine(str);
                }

            }

            else if (str.IsAllUppercase(0))
            {
                str.PrintAllLowercase(0);
            }

            else if (str[0] >= 'a' && str[0] <= 'z' && str.IsAllUppercase(1))
            {
                ch = char.ToUpper(str[0]);
                Console.Write(ch);
                str.PrintAllLowercase(1);
            }
            else
            {
                Console.WriteLine(str);
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication16
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            char c = s.First();
            string s2 = s.ToUpper();
            char c2 = s2.First();
            s2=s2.Remove(0, 1);
            string s3 = s.ToLower();
            char c3 = s3.First();
            s3 = s3.Remove(0, 1);

            int a=0, b = 0;

            for (int i = 1; i < s.Length; i++)
            {
                if (c >= 65 && c <= 90 && s[i] >= 65 && s[i] <= 90)
                {
                    a++;
                }
                if (c >= 97 && c <= 122 && s[i] >= 65 && s[i] <= 90)
                {
                    b++;
                }
            }
            if (a == s.Length-1) Console.WriteLine(c3+s3);
            else if (b == s.Length-1) Console.WriteLine(c2 + s3.ToLower());
            else Console.WriteLine(s);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeForcesModulA
{
    class Program
    {
        static void Main(string[] args)
        {

            StringBuilder str = new StringBuilder(Console.ReadLine());
            int k = 0;
            for (int i =0; i < str.Length; i++)
            {
                if (str[i] >= 'A' && str[i] <= 'Z') k++;
                else if (str[0] <= 'a' && str[0] <='z' && str[i] >= 'A' && str[i] <= 'Z')
                {
                    k++;
                }
            }
            if (k == str.Length || k + 1 == str.Length && str.Length > 4)
            {
                Console.Write(str);
            }
            else {
                Console.Write(char.ToUpper(str[0]));
                for (int i = 1; i < str.Length; i++)
                {
                    if (str[i] >= 'A' && str[i] <= 'Z') Console.Write((char)(str[i] + 32));
                    else Console.Write(str[i]);
                }
                }
            Console.ReadLine();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _131A
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            byte[] p = Encoding.Unicode.GetBytes(s);
            List<byte> unicode = new List<byte>();
            foreach (byte elem in s)//убираем "0"
            {
                if (elem != 0)
                    unicode.Add(elem);
            }

            if (unicode[1] > 96 && CapsCheck(unicode))//проверяем условие
                Change(unicode);

            foreach (byte elem in unicode)
            {
                Console.Write((char)elem);
            }
            //Console.WriteLine();
        }

        static bool CapsCheck(List<byte> u)
        {
            int k = 0;
            for(int i=1; i<u.Count; i++)
            {
                if (u[i] > 64 && u[i] < 91)
                    k++;
            }
            if (k == u.Count-1)
                return true;
            else
                return false;
        }

        static void Change(List<byte> u)
        {
            u[0] -= 32;
            for (int i = 1; i < u.Count; i++)
            {
                u[i] += 32;
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace Плиты
{
    class Program
    {
        static void Main(string[] args)
        {

            string slovo = Console.ReadLine();
            slovo.ToLower();
            slovo.ToCharArray();
            for(int i=1;i<slovo.Length;i++)
                Console.Write(slovo[0].ToString().ToUpper() + slovo[i]);
        }
    }
}

using System;

/// <summary>
/// Capslock.
/// </summary>
class CapsLock
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().ToCharArray();

        bool isInvalid = true;
        if (input.Length == 1)
        {
            if (char.IsLower(input[0]))
                isInvalid = false;
        }
        else
        {
            for (int i = 1; i < input.Length; i++)
            {
                if (char.IsLower(input[i]))
                {
                    isInvalid = false;
                    break;
                }
            }
        }

        if (isInvalid)
        {
            input[0] = char.IsUpper(input[0]) ? char.ToLowerInvariant(input[0]) : char.ToUpperInvariant(input[0]);
            for (int i = 1; i < input.Length; i++)
                input[i] = char.ToLowerInvariant(input[i]);
        }

        Console.WriteLine(input);
        //Console.ReadKey();
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            string word = Console.ReadLine();
            char[] carray = word.ToCharArray();

            var builder = new StringBuilder();

            for (int i = 0; i < carray.Length; i++)
            {

                if (i == 0)
                {

                    if (char.IsLower(carray[0]) || char.IsUpper(carray[0]))
                    {

                        char newword = char.ToUpper(carray[0]);

                        builder.Append(newword);

                    }
                }
                else
                {
                    if (char.IsLower(carray[i]) || char.IsUpper(carray[i]))
                    {

                        char secword = char.ToLower(carray[i]);

                        builder.Append(secword);

                    }

                }

            }
            Console.Write(builder);

        }

    }
}

using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            String str = Console.ReadLine();
            String res = "";
            if (str.Equals(str.ToUpper()))
            {
                res = str.ToLower();
                Console.WriteLine(res);
            }

            else if (str.Equals(str.ToLower()) && str.Length!=1)
            {
                res = str.ToLower();
                Console.WriteLine(res);
            }

            else if (str.Equals(str.ToLower()) && str.Length == 1)
            {
                res = str.ToUpper();
                Console.WriteLine(res);
            }

            else if (check(str) == true)
            {
                for (int i = 0; i < str.Length; i++)
                {
                    char c = str[i];
                    if (i == 0)
                    {
                        c = str.ToUpper()[0];
                        res += c;
                    }
                    else
                    {
                        res += Char.ToLower(c);
                    }
                }
                Console.WriteLine(res);
            }

            else
            {
                Console.WriteLine(str);
            }
         //   Console.ReadKey();
        }
        private static bool check(String s)
        {
            bool res = false;

            int l = 0;
            int u = 0;

            if (s.Equals(s.ToUpper()))
            {
                res = true;
            }

            else if ((s[0] == Char.ToLower(s[0])))
            {
                l++;
                for (int i = 1; i < s.Length; i++)
                {
                    if (s[i] == Char.ToUpper(s[i]))
                    {
                        u++;
                    }

                    else if (s[i] == Char.ToLower(s[i]))
                    {
                        l++;
                    }
                }

                if (l > 1 && u > 1)
                {
                    res = false;
                }

                else
                {
                    res = true;
                }
            }

            else if ((s[0] == Char.ToUpper(s[0])))
            {
                u++;
                for (int i = 1; i < s.Length; i++)
                {
                    if (s[i] == Char.ToUpper(s[i]))
                    {
                        u++;
                    }

                    else if (s[i] == Char.ToLower(s[i]))
                    {
                        l++;
                    }
                }

                if (l >= 1 && u >= 1)
                {
                    res = false;
                }

                else
                {
                    res = true;
                }
            }

            return res;
        }
    }
}

using System;

class Sample {
    public static void Main() {
      string str = Console.ReadLine();
      char[] arr =str.ToCharArray();
      int s = 0;
      for(int i=0;i<arr.Length;i++){
       if((int)arr[i]>=65&&(int)arr[i]<97){
        s++;
        }

      }

      if(s==arr.Length){
       Console.WriteLine(str.ToLower());
      }else if((int)arr[0]>=97&&s==arr.Length-1){
        Console.WriteLine(s);
       str = str.ToLower();
       arr =str.ToCharArray();
       arr[0] = (char)((int)(arr[0])-32);
       str = new string(arr);
       Console.Write(str);
      }else if((int)arr[0]>=97&&s>arr.Length-1){
       arr[0] = (char)((int)(arr[0])-32);
       str = new string(arr);
       Console.Write(str);
      }else{
       Console.Write(str);
      }
    }

}

using System;
using System.Linq;
using System.Text;
using System.Collections;
using System.Collections.Generic;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string l = Console.ReadLine();
            List<char> b = l.ToList<char>();
            int count = b.FindAll(x => char.IsUpper(x)).Count;
            if (char.IsUpper(b[0]))
                count--;
            if(l.Length - count - 1 < 1)
            {
                l = char.ToUpper(l[0]) + l.Remove(0, 1);
                for (int i = 1; i < l.Length; i++)
                {
                    string a = char.ToLower(l[i]).ToString();
                    l = l.Remove(i, 1);
                    l = l.Insert(i, a);
                }
            }
            Console.WriteLine(l);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace codeforces
{
    class Program
    {
        public static void check(string i)
        {
            string temp1 = i.ElementAt(0).ToString();
            string temp2 = i.Substring(1);
            string temp3 =i.Substring(1);
            temp2 = temp2.ToUpper();
            temp1 = temp1.ToUpper();

            if (temp1 == i.ElementAt(0).ToString()&&temp2==temp3)
            {
                string arr;
                arr = i.Substring(1);
                if (i.Substring(1) == arr)
                {
                    arr = arr.ToLower();
                    Console.WriteLine(i.ElementAt(0) + arr);
                    return;
                }

                    Console.WriteLine(i);

            }
            else{
                string temp4;
                temp4 = i.ElementAt(0).ToString();

                if (temp4 == i.ElementAt(0).ToString())
                {
                    Console.WriteLine(i);
                }
                else if (temp4 != i.ElementAt(0).ToString())
                {

               i = i.ToUpper();
                string arr;
                arr = i.Substring(1);

                arr = arr.ToLower();

                i = i.ElementAt(0) + arr;
                Console.WriteLine(i);
                }

            }
        }
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            check(input);

        }
    }
}

using System;
using System.Text;

namespace Test
{

    class Program
    {
        static void Main(string[] args)
        {
            string word = Console.ReadLine();
            int numOfChange = 0;
            bool flag;

            if(char.IsUpper(word[0]))
                flag = true;
            else
                flag = false;

            for (int i = 1; i < word.Length; i++)
            {
                if(char.IsUpper(word[i]) != flag)
                {
                    flag = !flag;
                    numOfChange++;
                }

                if(numOfChange == 2)
                {
                    Console.WriteLine(word);
                    return;
                }
            }

            StringBuilder _word = new StringBuilder(word.ToLower());

            _word[0] = char.ToUpper(_word[0]);
            Console.WriteLine(_word);

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    public class Program
    {
        public static void Main(String[] args )
        {
            string str = Console.ReadLine();
            str = str.First().ToString().ToUpper() + str.Substring(1).ToLower();
            Console.WriteLine(str);

        }
    }

}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int noha = 0;
            int i = 0;
            int j = 1;
            string word;
            word = Console.ReadLine();

            if (IsAllUpper(word))
            {
                Console.WriteLine(word.Substring(0, 1).ToUpper() + word.Substring(1, word.Length - 1).ToLower());
            }
            else if (word.Length==1)
            {
                Console.WriteLine(System.Char.ToUpper(char.Parse(word)));
            }
            else if (IsAllLOWER(word))
            {
                Console.WriteLine(word);
            }
            else
            {
                Console.WriteLine(word.Substring(0, 1).ToUpper() + word.Substring(1, word.Length - 1).ToLower());
            }

           /* if (System.Char.IsLower(char.Parse(word.Substring(0, 1))))
            {

                for (j = 1; j < word.Length; j++)
                {
                    if (System.Char.IsLower(char.Parse(word.Substring(j, 1))))
                    {
                        noha = 1; goto b;
                    }

                } Console.WriteLine(word.Substring(0, 1).ToUpper() + word.Substring(1, word.Length - 1).ToLower());

            }

            else if (System.Char.IsUpper(char.Parse(word.Substring(0, 1))))
            {
                for (i = 0; i < word.Length; i++)
                {
                    if (System.Char.IsLower(char.Parse(word.Substring(i, 1))))
                    {
                        // noha = 1; goto b;
                    }

                }
                Console.WriteLine(word.Substring(0, 1).ToUpper() + word.Substring(1, word.Length - 1).ToLower());

            }
        b: if (noha == 1) Console.WriteLine(word);*/
            Console.ReadLine();
        }
       static bool IsAllUpper(string input)
        {
            for (int i = 0; i < input.Length; i++)
            {
                if (!Char.IsUpper(input[i]))
                    return false;
            }
            return true;
        }

       static bool IsAllLOWER(string input)
       {
           for (int i = 0; i < input.Length; i++)
           {
               if (Char.IsUpper(input[i]))
                   return false;
           }
           return true;
       }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;

namespace BulkaProga
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            if (!char.IsUpper(line[0]) && line.Count(x => !char.IsUpper(x)) > 0 && line.Count(x => char.IsUpper(x)) == 0)
                Console.WriteLine(line[0].ToString().ToUpper() + line.Substring(1).ToLower());
            else
                Console.WriteLine(line);
        }
    }
}

using System;
using System.Linq;

namespace CapsLock
{
    class Test
    {
        public
        static void Main(string[] args)
        {

            string input = Console.ReadLine();
            if (char.IsLower(input[0]))
            {
                if (input.Remove(0, 1).Any(c => char.IsLower(c)))
                    Console.WriteLine(input);
                else
                    Console.WriteLine("{0}{1}", Char.ToUpper(input[0]), input.Remove(0, 1).ToLower());
            }
            else
            {
                if(input.Any(c => char.IsLower(c)))
                    Console.WriteLine(input);
                else
                    Console.WriteLine("{0}{1}",  input[0], input.Remove(0, 1).ToLower());
            }
           //Console.ReadLine();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Codeforces
{
    class Program
    {
        static void _158a()
        {
            string[] input = Console.ReadLine().Split();
            int n = int.Parse(input[0]);
            int k = int.Parse(input[1]);
            int[] points = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            int kth = points[k-1];
            Console.WriteLine(points.Count(x => x > 0 && x >= kth));
        }
        static void _71a()
        {
            int n = int.Parse(Console.ReadLine());
            string[] words=new string[n];
            for (int i = 0; i < n; i++)
            {
                words[i] = Console.ReadLine();
            }
            for (int i = 0; i < n; i++)
            {
                if (words[i].Length > 10)
                {
                    //Console.WriteLine(words[i][0] + (words[i].Length - 2) + words[i].Last());
                    Console.Write(words[i][0]);
                    Console.Write(words[i].Length - 2);
                    Console.Write(words[i].Last());
                    Console.WriteLine();
                }
                else
                    Console.WriteLine(words[i]);
            }
        }
        static void _118a()
        {
            string input = Console.ReadLine();
            input=input.ToLower();
            char[] vowels=new[] { 'a', 'o', 'y', 'e', 'u', 'i' };
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < input.Length; i++)
                if (!vowels.Contains(input[i]))
                    sb.Append("." + input[i]);
            Console.WriteLine(sb.ToString());
        }
        static void _158b()
        {
            int n = int.Parse(Console.ReadLine());
            int count = 0;
            string s = Console.ReadLine();
            int _1,_2,_3,_4;
            _1 = _2 = _3 = _4 = 0;
            for (int i = 0; i < s.Length; i++)
            {
                switch (s[i])
                {
                    case '1': _1++;
                        break;
                    case '2': _2++;
                        break;
                    case '3': _3++;
                        break;
                    case '4': _4++;
                        break;
                }
            }
            count = _4;
            int min = Math.Min(_1, _3);
            _1 -= min; _3 -= min;
            count += min;
            count += _3;
            int d2 = _2 / 2;
            count += d2;
            _2 -= d2*2;
            if (_2 == 0)
            {
                count += (int)Math.Ceiling((double)_1 / 4);
            }
            else
            {
                count++;
                _1 -= 2;
                if (_1 > 0)
                    count += (int)Math.Ceiling((double)_1 / 4);
            }
            Console.WriteLine(count);
        }
        static void _50a()
        {
            string[] ss = Console.ReadLine().Split();
            int m = int.Parse(ss[0]);
            int n = int.Parse(ss[1]);
            int f = 0, s = 0;
            f = m / 2 * n;
            s = n / 2 * m;
            bool first = f > s;
            if (first)
            {//gor
                if (m % 2 == 1)
                    f += n / 2;
            }
            else
            { //ver
                if (n % 2 == 1)
                    s += m / 2;
            }
            Console.WriteLine(first ? f : s);
        }
        static void _116a()
        {
            int n = int.Parse(Console.ReadLine());
            int count = 0, curr = 0;
            for (int i = 0; i < n; i++)
            {
                string[] ss = Console.ReadLine().Split();
                int f = int.Parse(ss[0]);
                int s = int.Parse(ss[1]);
                curr += - f + s;
                if (curr > count)
                    count = curr;
            }
            Console.WriteLine(count);
        }
        static void _82a()
        {
            int n = int.Parse(Console.ReadLine());
            string[] names = { "Sheldon", "Leonard", "Penny", "Rajesh", "Howard" };

            int gr = 1, end = 5;
            while (end < n)
            {
                gr++;
                end = (int)(5 * (-1 + Math.Pow(2, gr)));
            }
            int need = 4;
            int minus = (int)Math.Pow(2, gr - 1);
            end -= minus;
            while (end >= n)
            {
                minus = (int)Math.Pow(2, gr - 1);
                end-=minus;
                need--;
            }
            Console.WriteLine(names[need]);
        }
        static void _231a()
        {
            int n = int.Parse(Console.ReadLine());
            int count=0;
            for (int i = 0; i < n; i++)
            {
                string t = Console.ReadLine();
                if (t.Count(x => x == '1') >= 2)
                    count++;
            }
            Console.WriteLine(count);
        }
        static void _131a()
        {
            string s = Console.ReadLine();
            bool onlyfncaps = char.IsLower(s[0]);
            bool allcaps = false;
            if (s.All(x => char.IsLower(x))&& s.Length==1)
            {
                s = s.ToUpper();
                allcaps = true;
            }
            if (!allcaps && s.All(x => char.IsUpper(x)) && s.Length > 1)
            {
                s = s.ToLower();
                allcaps = true;
            }
            if (onlyfncaps && !allcaps)
                for (int i = 1; i < s.Length; i++)
                    if (!char.IsUpper(s[i]))
                    {
                        onlyfncaps = false;
                        break;
                    }
            if (onlyfncaps&&!allcaps)
            {
                char[] tt = s.ToCharArray();
                for (int i = 0; i < s.Length; i++)
                    if (char.IsUpper(tt[i]))
                    {
                        tt[i] = char.ToLower(tt[i]);
                    }
                    else
                    {
                        tt[i] = char.ToUpper(tt[i]);
                    }
                s = string.Join("", tt);
            }
            Console.WriteLine(s);
        }

        static void Main(string[] args)
        {
            _131a();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace cAPSLOCK___codeforces
{
    class Program
    {
        static void Main(string[] args)
        {

            string s = Console.ReadLine().ToString();
            string result = string.Empty;

            if (s.Length == 1)
            {
                if (char.IsLower(s[0]))
                {
                    Console.WriteLine(char.ToUpper(s[0]).ToString());
                }
                else

                    Console.WriteLine(char.ToUpper(s[0]).ToString());
            }
            else if (char.IsUpper(s[0]) && char.IsLower(s[1]))
            {
                Console.WriteLine(s);

            }

            else if (char.IsLower(s[0]))
            {
                result = char.ToUpper(s[0]).ToString();

                for (int i = 1; i < s.Length; i++)
                {
                    if (char.IsLower(s[i]))
                    {
                        Console.WriteLine(s);
                        result = string.Empty;
                        break;
                    }
                    result = result + char.ToLower(s[i]).ToString();
                }

                if (result != string.Empty)
                {
                    Console.WriteLine(result);
                }

            }
            if ((char.IsUpper(s[0]) && s.Length > 1) && char.IsUpper(s[1]))
            {
                result = char.ToLower(s[0]).ToString() + char.ToLower(s[1]).ToString() ;

                for (int i = 2; i < s.Length; i++)
                {
                    if (char.IsLower(s[i]))
                    {
                        Console.WriteLine(s);
                        result = string.Empty;
                        break;
                    }
                    result = result + char.ToLower(s[i]).ToString();
                }

                if (result != string.Empty)
                {
                    Console.WriteLine(result);
                }

            }

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace add
{
    class Program
    {
        static void Main(string[] args)
        {
            string a=Console.ReadLine();
            string b=a.Substring(0,1);
            string c=a.Substring(1,a.Length-1);
            string d=c.ToUpper();
            if(c==d)
            {
            Console.WriteLine(b.ToUpper()+d.ToLower());
            }
            else
            {
            Console.WriteLine(a);
            }
        }
}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C1CapsLock
{
    class Program
    {
        static void Main(string[] args)
        {
            string usrInput = Console.ReadLine();

            if (case1(usrInput))
                Console.WriteLine($"{usrInput.Substring(0, 1).ToUpper()}{usrInput.Substring(1).ToLower()}");
            else if (case2(usrInput))
                Console.WriteLine("it is case 2");
            else
                Console.WriteLine(usrInput);
            Console.ReadLine();
            //bool stringFlag = false;

            //for (int i = 0; i < usrInput.Length; i++)
            //{
            //    if(char.IsLower(usrInput[0]))
            //    {
            //        for (int j = 1; j < usrInput.Length; j++)
            //        {
            //            if (char.IsUpper(usrInput[i]))
            //            {

            //            }
            //        }
            //        Console.WriteLine("first letter is small and all others are capital");
            //    }
            //}

        }
        static bool case1(string str)
        {
            for (int i = 0; i < str.Length; i++)
            {
                if (!char.IsUpper(str[i]))
                    return false;
            }
            return true;
        }
        static bool case2(string str2)
        {
            return case1(str2.Substring(1)) && char.IsLower(str2[0]);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication15
{
    class Program
    {
        static void Main(string[] args)
        {
            char []ch = Console.ReadLine().ToCharArray();

            for (int i = 1; i < ch.Length; i++)
            {
                if (Char.IsUpper(ch[i]))
                    ch[i] = Char.ToLower(ch[i]);
                if(Char.IsLower(ch[i]))
                    ch[i] = Char.ToLower(ch[i]);
            }
            ch[0] = Char.ToUpper(ch[0]);
            Console.WriteLine(ch);
            Console.ReadLine();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C_cAPSlOCK
{
    class Program
    {
        public static bool CheckIfAllCharsAreCaps(List<char> list)
        {
            bool result = false;
            for (int i = 0; i < list.Count; i++)
                if (char.IsUpper(list[i]))
                    result = true;
                else
                {
                    result = false;
                    break;
                }
            return result;
        }
        public static bool CheckIfAllCharsAreCapsExceptFirst(List<char> list)
        {
            bool result = false;
            if (char.IsUpper(list[0]) == false)
            {
                list.RemoveAt(0);
                for (int i = 0; i < list.Count; i++)
                    if (char.IsUpper(list[i]))
                        result = true;
                    else
                    {
                        result = false;
                        break;
                    }
            }
            return result;

        }
        public static string ToLowerCase(List<char> list)
        {
            for (int i = 0; i < list.Count; i++)
                list[i] = char.Parse(list[i].ToString().ToLower());

            string result = string.Join("", list);
            return result;
        }
        static void Main(string[] args)
        {
            string word = Console.ReadLine();
            List<string> letters = new List<string>();
            List<char> temp = new List<char>();

            foreach (char item in word)
            {
                temp.Add(item);
            }

            bool check = CheckIfAllCharsAreCaps(temp);
            bool check2 = CheckIfAllCharsAreCapsExceptFirst(temp);

            if (check == true)
            {
                word = ToLowerCase(temp);
                Console.WriteLine(word);
            }
            else
            if (check2 == true)
            {
                foreach (char item in word)
                    letters.Add(item.ToString().ToLower());

                letters[0] = letters[0].ToUpper();
                word = string.Join("", letters);
                Console.WriteLine(word);
            }
            else
                Console.WriteLine(word);

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _123
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int size = s.Length;
            for (int i = 1; i < size; i++)
                if(!char.IsUpper(s[i]))
                {
                    Console.WriteLine(s);
                }
            for (int i = 0; i < size; i++)
                if(char.IsUpper(s[i]))
                {
                    Console.Write(s[i].ToString().ToLower());
                }
                else
                {
                    Console.Write(s[i].ToString().ToUpper());
                }
        }
    }
}

using System;

namespace ConsoleApp
{
    class Program
    {
        static void Main()
        {
            string word = Console.ReadLine();
            int countUpper = 0, countLower = 0, i;
            bool t = false;
            for (i = 0; i < word.Length; i++)
            {
                if (char.IsUpper(word[0]))
                {
                    t = true;
                }
                    if (char.IsUpper(word[i])) countUpper++;
                else if (char.IsLower(word[i])) countLower++;
            }

            if (countLower == 0)
            {
                    string x = word.ToLower();
                    string z = x[0].ToString();
                    string l = z.ToUpper();
                    string sub = x.Substring(1);
                    Console.WriteLine(l + sub);
                Console.ReadLine();
            }

               if(char.IsLower(word[0]))
            {
                if (countLower == 1)
                {
                    string x = word.ToLower();
                    string z = x[0].ToString();
                    string l = z.ToUpper();
                    string sub = x.Substring(1);
                    Console.WriteLine(l + sub);
                    Console.ReadLine();
                }
            }

            if (char.IsUpper(word[0]))
                {
                if(countUpper == 1)
                {
                    Console.WriteLine(word);
                    Console.ReadLine();
                }

            }

            if (char.IsLower(word[0]))
            {
                if(countLower > 1)
                {
                    Console.WriteLine(word);
                    Console.ReadLine();
                }
            }
            if (char.IsUpper(word[0]))
            {
                if (countLower >= 1)
                {
                    Console.WriteLine(word);
                    Console.ReadLine();
                }
            }

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace task131A
{
    class Program
    {
        static string Answer(string str)
        {
            Dictionary<char, char> d1 = new Dictionary<char, char>();
            string temp = str.ToLower();
            for (char i = 'a'; i <= 'z'; i++)
            {
                d1.Add(i, (char)((int)i - 32));
            }
            short k = 0;
            for (Int32 i = 0; i < str.Length; i++)
            {
                if (d1.ContainsKey(str[i]))
                {
                    k++;
                }
            }
            if (k > 1) return str;
            return d1[temp[0]] + temp.Substring(1);
        }
        static void Main(string[] args)
        {
            string temp = Console.ReadLine();
            Console.WriteLine(Answer(temp));
           //Console.ReadLine();
        }
    }
}

using System;
using System.Collections.Generic;

namespace CapsLock
{
    class Program
    {
        static void Main(string[] args)
        {
            string ds = Console.ReadLine().ToLower();
            string a = ds[0] + "";
            string b =a.ToUpper();
            string res ="";
            if (ds.Length > 1)
                for (int i = 1; i < ds.Length; i++)
                    res += ds[i];
            Console.WriteLine(b+res);

        }
    }
}

using System;
using System.IO;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
#if !ONLINE_JUDGE
            Console.SetIn(new StreamReader("input.txt"));
#endif

            var inp = Console.ReadLine();
            if (inp == inp.ToUpper()) {
                inp = inp.ToLower();
            }

            if(inp.Substring(1) == inp.Substring(1).ToUpper())
            {
                if (inp.Length == 1)
                {
                    inp = inp.ToLower();
                }
                else
                {
                    inp = inp.Substring(0, 1).ToUpper() + inp.Substring(1).ToLower();
                }
            }

            Console.WriteLine(inp);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ejercicios
{
    class Program
    {
        static string funcion (string str)
        {
            string newStr = "", first;

            if (str.Length == 1 && isLower(str[0]))
                return str.ToUpper();

            if (str.Length == 1 && isUpper(str[0]))
                return str;

            if (isUpper(str[0])){
                if (rest(str))
                    return str.ToLower();
                else
                    return str;
            }
            else
            {
                if (rest(str))
                {
                    first = str[0].ToString().ToUpper();
                    newStr = str.Substring(1);
                    newStr = first + newStr.ToLower();
                    return newStr;
                }
                else
                {
                    return str;
                }

            }
        }

        static bool rest (string str){
            for (int i = 1; i < str.Length; i++)
            {
                if (isLower(str[i]))
                    return false;
            }
            return true;
        }

        static bool isUpper(char letter)
        {
            string alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            for (int i = 0; i < alpha.Length; i++)
            {
                if (letter == alpha[i])
                return true;
            }
            return false;
        }

        static bool isLower(char letter)
        {
            string alpha = "abcdefghijklmnopqrstuvwxyz";
            for (int i = 0; i < alpha.Length; i++)
            {
                if (letter == alpha[i])
                    return true;
            }
            return false;
        }

        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            Console.WriteLine(funcion(str));
        }
    }
}

using System;

namespace A_cAPSLOCk
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string s = Console.ReadLine();

            char[] ch = new char[s.Length];
            for (int i = 0; i < s.Length; i++)
            {
                ch[i] = s[i];
                if (i == 0 && ch[i] > 90)
                    ch[i] = Convert.ToChar(ch[i] - 32);
                if (i > 0 && (ch[i] < 91))
                    ch[i] = Convert.ToChar(ch[i] + 32);
            }

            s = Convert.ToString(ch[0]);
            for (int i = 1; i < ch.Length;i++)
            {
                s = s + ch[i];
            }

            Console.WriteLine($"{s}");

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A.cAPS_lOCK
{
    class Program
    {
        static void Main(string[] args)
        {
            string word = Console.ReadLine();
            string alpha = "abcdefghijklmnopqrstuvwxyz";
            string alphacap = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            word = word.ToLower();
                for(int j=0;j<alpha.Length;j++)
                {
                    if (word[0] == alpha[j])
                    {
                        StringBuilder a = new StringBuilder(word);
                        a[0] = alphacap[j];
                        word = a.ToString();
                        Console.WriteLine(word);

                    }

            }

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Codeforces
{
    class Program
    {
        static void _158a()
        {
            string[] input = Console.ReadLine().Split();
            int n = int.Parse(input[0]);
            int k = int.Parse(input[1]);
            int[] points = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            int kth = points[k-1];
            Console.WriteLine(points.Count(x => x > 0 && x >= kth));
        }
        static void _71a()
        {
            int n = int.Parse(Console.ReadLine());
            string[] words=new string[n];
            for (int i = 0; i < n; i++)
            {
                words[i] = Console.ReadLine();
            }
            for (int i = 0; i < n; i++)
            {
                if (words[i].Length > 10)
                {
                    //Console.WriteLine(words[i][0] + (words[i].Length - 2) + words[i].Last());
                    Console.Write(words[i][0]);
                    Console.Write(words[i].Length - 2);
                    Console.Write(words[i].Last());
                    Console.WriteLine();
                }
                else
                    Console.WriteLine(words[i]);
            }
        }
        static void _118a()
        {
            string input = Console.ReadLine();
            input=input.ToLower();
            char[] vowels=new[] { 'a', 'o', 'y', 'e', 'u', 'i' };
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < input.Length; i++)
                if (!vowels.Contains(input[i]))
                    sb.Append("." + input[i]);
            Console.WriteLine(sb.ToString());
        }
        static void _158b()
        {
            int n = int.Parse(Console.ReadLine());
            int count = 0;
            string s = Console.ReadLine();
            int _1,_2,_3,_4;
            _1 = _2 = _3 = _4 = 0;
            for (int i = 0; i < s.Length; i++)
            {
                switch (s[i])
                {
                    case '1': _1++;
                        break;
                    case '2': _2++;
                        break;
                    case '3': _3++;
                        break;
                    case '4': _4++;
                        break;
                }
            }
            count = _4;
            int min = Math.Min(_1, _3);
            _1 -= min; _3 -= min;
            count += min;
            count += _3;
            int d2 = _2 / 2;
            count += d2;
            _2 -= d2*2;
            if (_2 == 0)
            {
                count += (int)Math.Ceiling((double)_1 / 4);
            }
            else
            {
                count++;
                _1 -= 2;
                if (_1 > 0)
                    count += (int)Math.Ceiling((double)_1 / 4);
            }
            Console.WriteLine(count);
        }
        static void _50a()
        {
            string[] ss = Console.ReadLine().Split();
            int m = int.Parse(ss[0]);
            int n = int.Parse(ss[1]);
            int f = 0, s = 0;
            f = m / 2 * n;
            s = n / 2 * m;
            bool first = f > s;
            if (first)
            {//gor
                if (m % 2 == 1)
                    f += n / 2;
            }
            else
            { //ver
                if (n % 2 == 1)
                    s += m / 2;
            }
            Console.WriteLine(first ? f : s);
        }
        static void _116a()
        {
            int n = int.Parse(Console.ReadLine());
            int count = 0, curr = 0;
            for (int i = 0; i < n; i++)
            {
                string[] ss = Console.ReadLine().Split();
                int f = int.Parse(ss[0]);
                int s = int.Parse(ss[1]);
                curr += - f + s;
                if (curr > count)
                    count = curr;
            }
            Console.WriteLine(count);
        }
        static void _82a()
        {
            int n = int.Parse(Console.ReadLine());
            string[] names = { "Sheldon", "Leonard", "Penny", "Rajesh", "Howard" };

            int gr = 1, end = 5;
            while (end < n)
            {
                gr++;
                end = (int)(5 * (-1 + Math.Pow(2, gr)));
            }
            int need = 4;
            int minus = (int)Math.Pow(2, gr - 1);
            end -= minus;
            while (end >= n)
            {
                minus = (int)Math.Pow(2, gr - 1);
                end-=minus;
                need--;
            }
            Console.WriteLine(names[need]);
        }
        static void _231a()
        {
            int n = int.Parse(Console.ReadLine());
            int count=0;
            for (int i = 0; i < n; i++)
            {
                string t = Console.ReadLine();
                if (t.Count(x => x == '1') >= 2)
                    count++;
            }
            Console.WriteLine(count);
        }
        static void _131a()
        {
            string s = Console.ReadLine();
            bool onlyfncaps = char.IsLower(s[0]);
            bool allcaps = false;

            if (s.All(x => char.IsLower(x)))
            {
                s = s.ToUpper();
                allcaps = true;
            }
            if (!allcaps && s.All(x => char.IsUpper(x)))
            {
                s = s.ToLower();
                allcaps = true;
            }
            if (onlyfncaps && !allcaps)
                for (int i = 1; i < s.Length; i++)
                    if (!char.IsUpper(s[i]))
                    {
                        onlyfncaps = false;
                        break;
                    }
            if (onlyfncaps)
            {
                char[] tt = s.ToCharArray();
                for (int i = 0; i < s.Length; i++)
                    if (char.IsUpper(tt[i]))
                    {
                        tt[i] = char.ToLower(tt[i]);
                    }
                    else
                    {
                        tt[i] = char.ToUpper(tt[i]);
                    }
                s = string.Join("", tt);
            }
            Console.WriteLine(s);
        }

        static void Main(string[] args)
        {
            _131a();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CAPSLOCK
{
    class Program
    {
        static void Main(string[] args)
        {
            var Word = Console.ReadLine();
            var Upper = 0;

            foreach (var item in Word)
            {
                if (char.IsUpper(item))
                    Upper++;
            }
            if (Upper == Word.Length || char.IsLower(Word[0]))
            {
                var Lower = char.ToUpper(Word[0]) + Word.Substring(1).ToLower();
                Console.WriteLine(Lower);
            }
            else
                Console.WriteLine(Word);
        }

    }
}

using System;

/// <summary>
/// Capslock.
/// </summary>
class CapsLock
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().ToCharArray();

        bool isValid = false;
        if (input.Length == 1)
        {
            if (char.IsUpper(input[0]))
                isValid = true;
        }
        else
        {
            for (int i = 1; i < input.Length; i++)
            {
                if (char.IsLower(input[i]))
                {
                    isValid = true;
                    break;
                }
            }
        }

        if (!isValid)
        {
            input[0] = char.ToUpper(input[0]);
            for (int i = 1; i < input.Length; i++)
                input[i] = char.ToLower(input[i]);
        }

        Console.WriteLine(input);
    }
}

using System;

namespace CF_131A
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();

            char[] ch = input.ToCharArray();

            if(ch[0] >= 97 && ch.Length == 1)
            {
                Console.WriteLine((char)(ch[0] - 32));
            }
            else if(ch[0] >= 97 && ch.Length > 1)
            {
                ch[0] = (char)(ch[0] - 32);
                for(int i=1; i<ch.Length; i++)
                {
                    if(ch[i] >= 65 && ch[i] <= 90)
                    {
                        ch[i] = (char)(ch[i] + 32);
                    }
                }
                Console.WriteLine(ch);
            }
            else if(ch[0] >= 65 && ch[0] <= 90 && ch.Length > 1)
            {
                for (int i = 1; i < ch.Length; i++)
                {
                    if (ch[i] >= 65 && ch[i] <= 90)
                    {
                        ch[i] = (char)(ch[i] + 32);
                    }
                }
                Console.WriteLine(ch);
            }
            else
            {
                Console.WriteLine(ch);
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Probador_de_Codigo
{
    class Program
    {
        static void Main(string[] args)
        {
            string entrada = Console.ReadLine();
            Console.WriteLine(entrada[0].ToString().ToUpper() + entrada.ToLower().Substring(1, entrada.Length - 1));
        }
    }
}

using System;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        string input = Console.ReadLine();
        StringBuilder output = new StringBuilder();
        int upperCase = 0;
        int lowerCase = 0;
        for (int i = 0; i < input.Length; i++)
        {
            if (input[i] >= 65 && input[i] <= 97)
                upperCase++;
            else if (input[i] >= 97 && input[i] <= 123)
                lowerCase++;
        }
        if (upperCase == input.Length || upperCase == input.Length - 1)
            for (int i = 0; i < input.Length; i++)
            {
                if (input[0] >= 65 && input[0] < 97 && upperCase == input.Length-1)
                {
                    output.Append(input);
                    break;
                }
                else if (input[0] >= 97 && input[0] < 123 && upperCase == input.Length - 1)
                {
                    if(i==0)
                        output.Append(input[i].ToString().ToUpper());
                    else
                        output.Append(input[i].ToString().ToLower());
                }
                else
                    output.Append(input[i].ToString().ToLower());
            }
        else if (lowerCase == input.Length)
        {
            for (int i = 0; i < input.Length; i++)
            {
                output.Append(input[i].ToString().ToLower());
            }
        }
        else
            output.Append(input);
        Console.WriteLine(output);
    }

}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _131A_CapsLock
{
    static class Program
    {
        public static bool IsAllUppercase(this string str, int start)
        {
            int i = 0;
            for (i = start; i < str.Length; i++)
            {
                if (str[i] >= 'a' && str[i] <= 'b') return false;
            }
            return true;
        }

        static void PrintAllLowercase(this string str, int start)
        {
            int i = 0;
            for (i = start; i < str.Length; i++)
            {
                Console.Write(str[i]);
            }
            Console.Write("\n");
        }
        static void Main(string[] args)
        {
            int i = 0;
            string str = Console.ReadLine();
            char ch;

            if (str.Length==1)
            {
                if (str[0] >= 'a' && str[0] <= 'z')
                {
                    ch = char.ToUpper(str[0]);
                    Console.WriteLine(ch);
                }
                else
                {
                    Console.WriteLine(str);
                }

            }

            else if (str.IsAllUppercase(0))
            {
                Console.Write(str[0]);
                str.PrintAllLowercase(1);
            }

            else if (str[0] >= 'a' && str[0] <= 'z' && str.IsAllUppercase(1))
            {
                ch = char.ToUpper(str[0]);
                Console.Write(ch);
                str.PrintAllLowercase(1);
            }
            else
            {
                Console.WriteLine(str);
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            String team = Console.ReadLine();
            String newTeam = team.Remove(0,1);
            String output = null;

            newTeam = newTeam.ToLower();
            char firstLetter = team[0];

            if (char.IsLower(firstLetter) == true)
            {
                output = string.Concat(team.ToUpper()[0].ToString(),newTeam);
            }
            else
                output = string.Concat(firstLetter.ToString() + newTeam);

            Console.WriteLine(output);
            Console.ReadLine();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            int count1 = 0;//represent if all caracter is upper
            int count2 = 0;//represent if all caracter is upper expept first latter
            string str = Console.ReadLine();
            for (int i = 0; i < str.Length; i++)
            {
                if (char.IsUpper(str[i]))
                {
                    count1++;
                }
            }
             if(char.IsLower(str[0]))
                {
                    count2++;
                }
            for (int i = 1; i < str.Length; i++)
            {
                if (char.IsLower(str[i]))
                {
                    count2++;
                }
            }
            if (count1 == str.Length)
            {
                for (int i = 0; i < str.Length; i++)
                {
                    char.ToUpper(str[i]);
                }
                Console.WriteLine(str);
            }
            else if (count2 == str.Length)
            {
                char.ToUpper(str[0]);
                for (int i = 1; i < str.Length; i++)
                {
                    char.ToLower(str[i]);
                }
                Console.WriteLine(str);
            }
            else
            {
                Console.WriteLine(str);
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C_cAPSlOCK
{
    class Program
    {
        public static bool CheckIfAllCharsAreCaps(List<char> list)
        {
            bool result = false;
            for (int i = 0; i < list.Count; i++)
                if (char.IsUpper(list[i]))
                    result = true;
                else
                {
                    result = false;
                    break;
                }
            return result;
        }
        public static bool CheckIfAllCharsAreCapsExceptFirst(List<char> list)
        {
            bool result = false;
            list.RemoveAt(0);
            for (int i = 0; i < list.Count; i++)
                if (char.IsUpper(list[i]))
                    result = true;
                else
                {
                    result = false;
                    break;
                }
            return result;

        }

        static void Main(string[] args)
        {
            string word = Console.ReadLine();
            List<string> letters = new List<string>();
            List<char> temp = new List<char>();

            foreach (char item in word)
            {
                temp.Add(item);
            }

            bool check = CheckIfAllCharsAreCaps(temp);
            bool check2 = CheckIfAllCharsAreCapsExceptFirst(temp);

            if (check == true || check2 == true)
            {
                foreach (char item in word)
                    letters.Add(item.ToString().ToLower());

                letters[0] = letters[0].ToUpper();
                word = string.Join("", letters);
                Console.WriteLine(word);
            }
            else
                Console.WriteLine(word);

        }
    }
}

using System;

class Problem
{
    public static void Main()
    {
        string word = Console.ReadLine();

        bool isUpper = true;
        for (int i = 1; i < word.Length; i++)
        {
            if (word[i] > 90)
            {
                isUpper = false;
                break;
            }
        }

        if (isUpper)
        {
            char[] chars = word.ToCharArray();

            if (chars[0] < 90)
            {
                chars[0] += (char)32;
            }

            for (int k = 1; k < chars.Length; k++)
            {
                chars[k] += (char)32;
            }

            word = string.Join(string.Empty, chars);
        }

        Console.WriteLine(word);
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Probador_de_Codigo
{
    class Program
    {
        static void Main(string[] args)
        {
            string entrada = Console.ReadLine();
            string mayuscula = entrada.ToUpper();
            if(entrada.Substring(1, entrada.Length - 1) == mayuscula.Substring(1, mayuscula.Length - 1))
                Console.WriteLine(entrada[0].ToString().ToUpper() + entrada.ToLower().Substring(1, entrada.Length - 1));
            else
                Console.WriteLine(entrada);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication15
{
    class Program
    {
        static void Main(string[] args)
        {
            char []ch = Console.ReadLine().ToCharArray();

            for (int i = 1; i < ch.Length; i++)
            {
                if (Char.IsUpper(ch[i]))
                    ch[i] = Char.ToLower(ch[i]);
                if(Char.IsLower(ch[i]))
                    ch[i] = Char.ToLower(ch[i]);
            }
            ch[0] = Char.ToUpper(ch[0]);
            Console.WriteLine(ch);
            Console.ReadLine();
        }
    }
}

using System;
namespace capslock
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                int sayac = 0;
                string sentence = Console.ReadLine();
                for (int i = 0; i < sentence.Length; i++)
                {
                    if (sentence[i]<=90)
                        sayac++;
                }
                if (sayac == sentence.Length)
                {
                    for (int i = 0; i < sentence.Length; i++)
                    {
                        Console.Write(Convert.ToChar(sentence[i] + 32));
                    }
                }
                else if (sentence[0] >= 'Z' && sayac == sentence.Length - 1)
                {
                    if (sentence[0] >= 'Z')
                        Console.Write(Convert.ToChar(sentence[0] - 32));
                    for (int i = 1; i < sentence.Length; i++)
                    {
                        if (sentence[i] <= (int)('Z'))
                            Console.Write(Convert.ToChar(sentence[i] + 32));
                        else
                            Console.Write(sentence[i]);
                    }
                }
                else
                    Console.Write(sentence);
                //65-90 A-Z        97-122 a-z
                Console.ReadKey();
            }
            catch {  }
        }
    }
}

using System;
using System.IO;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
#if !ONLINE_JUDGE
            Console.SetIn(new StreamReader("input.txt"));
#endif

            var inp = Console.ReadLine();
            if (inp == inp.ToUpper()) {
                inp = inp.ToLower();
            }

            if(inp.Substring(1) == inp.Substring(1).ToUpper())
            {
                if (inp.Length == 1)
                {
                    inp = inp.ToUpper();
                }
                else
                {
                    inp = inp.Substring(0, 1).ToUpper() + inp.Substring(1).ToLower();
                }
            }

            Console.WriteLine(inp);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _131A
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            string output = string.Empty;
            bool flag = true, bflag;
            if (str.Length != 0)
            {
                output = str[0].ToString().ToUpper();
            }
            for (int i = 1; i < str.Length; i++)
            {
                if (i == 1)
                {
                    if (str[i] >= 'a' && str[i] <= 'z')
                    {
                        flag = false;
                    }
                    else
                    {
                        flag = true;
                    }
                }
                else
                {
                    if (str[i] >= 'a' && str[i] <= 'z')
                    {
                        bflag = false;
                    }
                    else
                    {
                        bflag = true;
                    }
                    if (flag == bflag)
                    {
                        output += (str[i].ToString()).ToLower();
                    }
                    else
                    {
                        Console.WriteLine(str);
                        return;
                    }
                }
            }
            Console.WriteLine(output);
        }
    }
}

using System;

namespace CodeForce
{
    class _131A_CapsLock
    {
        static void Main()
        {
            string input = Console.ReadLine();

            // 첫번째가 대문자
            if(input[0] >= 'A' && input[0] <= 'Z')
            {
                // 이후 소문자가 나오면 그대로 출력
                for(int i = 1; i < input.Length; i++)
                {
                    if (input[0] >= 'a' && input[0] <= 'z')
                    {
                        Console.WriteLine(input);
                        return;
                    }
                }
                // 모두 대문자일경우
                Console.WriteLine(input.ToLower());
            }
            // 첫번째가 소문자
            else
            {
                // 이후 소문자가 나오면 그대로 출력
                for (int i = 1; i < input.Length; i++)
                {
                    if (input[0] >= 'a' && input[0] <= 'z')
                    {
                        Console.WriteLine(input);
                        return;
                    }
                }
                // 모두 대문자일경우
                Console.WriteLine("{0}{1}", Char.ToUpper(input[0]), input.Remove(0, 1).ToLower());
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Training
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var l = s.Length;
            int co = 0;
            for (var i = 1; i < l; i++)
            {
                if (char.IsUpper(s[i]))
                {
                    co++;
                }
                else
                {
                    Console.WriteLine(s);
                    return;
                }
            }

            var r = s.First().ToString().ToUpper() + s.Substring(1).ToLower();

            Console.WriteLine(r);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            string input;
            input = Console.ReadLine();
            input = input.ToUpper();
            string arr ;
            arr = input.Substring(1);
            arr = arr.ToLower();
            input = input.ElementAt(0) + arr;
            Console.WriteLine(input);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace Olymp_dop
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            s = s[0].ToString().ToUpper() + s.Substring(1, s.Length - 1).ToLower();
            Console.WriteLine(s);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace cAPSLOCK
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            char[] line_as_char = line.ToCharArray();
            int[] line_as_int =new int[line_as_char.Length];

            //char[] line_chars_count;
            if (line_as_char.Length == 1)
            {
                int char_value = (int)line_as_char[0];
                if (char_value >= 65 && char_value <= 90)
                {
                    Console.WriteLine(line_as_char[0]);
                    return;
                }
                else
                {
                    Console.WriteLine((char)(char_value - 32));
                    return;
                }
            }
            else
            {
                int state_flag = 0;
                int f_char = (int)line_as_char[0];
                if(f_char >= 65 && f_char <= 90)
                {
                    state_flag = 1;
                }

                int another_state = 0;
                int c_char;
                for (int i = 1; i < line_as_char.Length; i++)
                {
                     c_char = (int)line_as_char[i];
                    if (c_char >= 65 && c_char <= 90)
                    {
                        another_state = 1;
                        line_as_int[i] =i;
                    }
                    else
                    {
                        another_state *= 0;
                        break;
                    }
                }

                if (((state_flag == 1) && (another_state == 1)) || ((state_flag == 0) && (another_state == 1)))
                {
                    if(state_flag == 1)
                    {
                     line_as_char[0] = (char)((int)line_as_char[0] + 32);
                    }
                    else
                    {
                         line_as_char[0] = (char)((int)line_as_char[0] - 32);
                    }
                    foreach (int x in line_as_int)
                    {
                        if (x == 0)
                        {
                            continue;
                        }
                        line_as_char[x] = (char)((int)line_as_char[x] + 32);
                    }

                }

            }

            Console.WriteLine(line_as_char);
            Console.ReadLine();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace Плиты
{
    class Program
    {
        static void Main(string[] args)
        {
            string proverka= Console.ReadLine();
            char[] slovo = proverka.ToCharArray();
            Console.Write(slovo[0].ToString().ToUpper());
            for (int i = 1; i < slovo.Length; i++)
                slovo[i].ToString().ToLower();
            for (int i = 1; i < slovo.Length; i++)
            {
                if (proverka.ToCharArray()[i] != slovo[i]) Console.WriteLine(slovo);
                else Console.WriteLine(proverka);
            }
        }
    }
}

using System;

namespace CodeForce1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            bool flag = false;
            if (char.IsLower(s[0]))
            {
                for (int i = 1; i < s.Length; i++)
                {
                    if (char.IsLower(s[i]))
                    {
                        flag = true;
                        break;
                    }
                }
            }
            else
            {
                for (int i = 0; i < s.Length; i++)
                {
                    if (char.IsLower(s[i]))
                    {
                        flag = true;
                        break;
                    }
                }
            }

            if (!flag)
            {
                s = s.ToLower();
                string result = s[0].ToString().ToUpper();
                result += s.Remove(0, 1);
                Console.WriteLine(result);
            }
            else
            {
                Console.WriteLine(s);
            }

            //Console.Read();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication15
{
    class Program
    {
        static void Main(string[] args)
        {
            char []ch = Console.ReadLine().ToCharArray();
            int k=0;
            for (int i = 0; i < ch.Length; i++)
              {
              if(Char.IsUpper(ch[i]))
                  k++;
              }
            if (k == ch.Length)
              {
                  for (int i = 0; i < ch.Length; i++)
                  {
                      ch[i] = Char.ToLower(ch[i]);
                  }
              }
        if (k==ch.Length-1)
        {
            ch[0] = Char.ToUpper(ch[0]);
            for (int i = 1; i < ch.Length; i++)
            {
                ch[i] = Char.ToLower(ch[i]);
            }
        }

            Console.WriteLine(ch);
            Console.ReadLine();
        }
    }
}

using System;
class test
{
	public static void Main()
	{
		string input = Console.ReadLine();
		input = input.ToLower();

		string inputcp = input;
		inputcp = inputcp.ToUpper();

		Console.Write(inputcp[0]);

		for(int i=1;i<input.Length;i++)
			Console.Write(input[i]);

		Console.WriteLine("");
	}
}

using System;

class Program
{
    static void Main(string[] args)
    {
        string input = Console.ReadLine();

        if (input.Length == 1)
        {
            Console.WriteLine(input.ToUpper());
            return;
        }

        char f = input[0] <= 'Z' ? input[0] : (char)(input[0] - 32);

        for (int i = 1; i < input.Length; i++)
        {
            if (input[i] <= 'Z')
            {
                Console.WriteLine($"{f}{input.Substring(1).ToLower()}");
                return;
            }
        }

        Console.WriteLine($"{f}{input.Substring(1)}");
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string word = Console.ReadLine();
            string word2 = word.ToUpper();

            int check = 2;

            for (int i = 1; i < word.Length - 1; i++)
            {
                if (word[i] == word2[i])
                {
                    check++;
                }
            }

            if (check == word.Length)
            {
                string word3 = word.ToLower();
                string a = Convert.ToString(word[0]);

                Console.Write(a.ToUpper());
                for (int i = 1; i < word.Length; i++)
                {
                    Console.Write(word3[i]);
                }

                Console.Read();
            }
            else
            {
                Console.WriteLine(word);
            }

            Console.Read();
        }
    }
}

using System;

class Problem
{
    public static void Main()
    {
        string word = Console.ReadLine();

        bool isUpper = true;
        for (int i = 1; i < word.Length; i++)
        {
            if (word[i] > 90)
            {
                isUpper = false;
                break;
            }
        }

        if (isUpper)
        {
            char[] chars = word.ToCharArray();

            if (chars[0] > 90)
            {
                chars[0] -= (char)32;
            }

            for (int k = 1; k < chars.Length; k++)
            {
                chars[k] += (char)32;
            }

            word = string.Join(string.Empty, chars);
        }

        Console.WriteLine(word);
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            int count1 = 0;//represent if all caracter is upper
            int count2 = 0;//represent if all caracter is upper expept first latter
            string str = Console.ReadLine();
            for (int i = 0; i < str.Length; i++)
            {
                if (char.IsUpper(str[i]))
                {
                    count1++;
                }
            }
             if(char.IsLower(str[0]))
                {
                    count2++;
                }
            for (int i = 1; i < str.Length; i++)
            {
                if (char.IsUpper(str[i]))
                {
                    count2++;
                }
            }
            if (count1 == str.Length)
            {
                for (int i = 0; i < str.Length; i++)
                {
                    char.ToUpper(str[i]);
                }
                Console.WriteLine(str);
            }
            else if (count2 == str.Length)
            {
                char.ToUpper(str[0]);
                for (int i = 1; i < str.Length; i++)
                {
                    char.ToLower(str[i]);
                }
                Console.WriteLine(str);
            }
            else
            {
                Console.WriteLine(str);
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _5
{
    class Program
    {
        static void Main(string[] args)
        {
            string n = Console.ReadLine();
            char[] c = n.ToCharArray();

            for (int i = 0; i < c.Length; i++)
            {

                if (c[i].CompareTo('a') < 0)
                {
                    char a = char.ToLower(c[i]);
                    c[i] = a;

                    continue;
                }
                if (c[i].CompareTo('a') > 0)
                {
                    char a = char.ToUpper(c[i]);
                    c[i] = a;
                }

            }
            c.ToString();
            Console.WriteLine(c);
        }

    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _131A
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            string output = string.Empty;
            for (int i = 0; i < str.Length; i++)
            {
                if (i == 0)
                {
                    output = str[0].ToString().ToUpper();
                    continue;
                }
                output += (str[i].ToString()).ToLower();
            }
            Console.WriteLine(output);
        }
    }
}

using System;
using System.Linq;
using System.Text.RegularExpressions;

namespace Codeforces
{
  class Program
  {
    static void Main(string[] args)
    {
      var word = Console.ReadLine();

      if(Regex.IsMatch(word, "^[a-z]+[A-Z]+$"))
      {
        word = Char.ToUpper(word[0]) + word.Substring(1).ToLower();
      }

      else if (Regex.IsMatch(word, "^[^a-z]+$"))
      {
        word = word.ToLower();
      }

      Console.WriteLine(word);
    }
  }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace codeforces
{
    class Program
    {
        public static void check(string i)
        {
            string temp1 = i.ElementAt(0).ToString();
            string temp2 = i.Substring(1);
            string temp3 =i.Substring(1);
            temp2 = temp2.ToUpper();
            temp1 = temp1.ToUpper();

            if (temp1 == i.ElementAt(0).ToString()&&temp2==temp3)
            {
                string arr;
                arr = i.Substring(1);
                if (i.Substring(1) == arr)
                {
                    arr = arr.ToLower();
                    Console.WriteLine(i.ElementAt(0) + arr);
                    return;
                }

                    Console.WriteLine(i);

            }
            else{
                string temp4;
                temp4 = i.ElementAt(0).ToString();
                temp4 = temp4.ToUpper();
                if (temp4 == i.ElementAt(0).ToString())
                {
                    Console.WriteLine(i);
                }
                else if (temp4 != i.ElementAt(0).ToString())
                {

               i = i.ToUpper();
                string arr;
                arr = i.Substring(1);

                arr = arr.ToLower();

                i = i.ElementAt(0) + arr;
                Console.WriteLine(i);
                }

            }
        }
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            check(input);

        }
    }
}

using System;
class test
{
	public static void Main()
	{
		string input = Console.ReadLine();
		input = input.ToLower();

		Console.WriteLine(input);
	}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace mohity_bara_Csharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string g="",s = Console.ReadLine();
            g += char.ToUpper(s.ElementAt(0));
            for (int i = 1; i < s.Length; i++)
                g += char.ToLower(s.ElementAt(i));
            Console.Write(g);

        }
    }
}

using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;

namespace WarmingUpC_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string word = Console.ReadLine();
            string result = "";
            if (word.Length == 1 && Char.IsLower(word[0]))
            {
                result = word.ToUpper();
            }
            else if (Char.IsLower(word[0]) && Char.IsUpper(word[1]))
            {
                result = Char.ToUpper(word[0]).ToString() + word.Substring(1, word.Length - 1).ToLower();
            }
            else if (Char.IsUpper(word[0]) && Char.IsUpper(word[1]))
            {
                result = word.ToLower();
            }
            else if (Char.IsLower(word[0]) && Char.IsLower(word[1]))
            {
                result = word.ToUpper();
            }
            Console.WriteLine(result);

        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace registr_slov
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
        Regex pr = new Regex(@"[A-Z]");
            MatchCollection pro = pr.Matches(s.Substring(1));

            if(s.Substring(1).Length==pro.Count){

                    Console.Write(s[0].ToString().ToUpper() + s.Substring(1).ToLower());
            }

            else { Console.WriteLine(s); }

        }
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeforcesProblem
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = GetStringInputFromLine();
            TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;
            input = textInfo.ToTitleCase(input);
            Console.WriteLine(input); ;

        }
        static int GetIntegerInputFromLine()
        {
            var input = Convert.ToInt32(Console.ReadLine().Trim());
            return input;
        }

        static int[] GetIntegerInputsFromLine()
        {
            var inputs = Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x.Trim())).ToArray();
            return inputs;
        }

        static long GetLongInputFromLine()
        {
            var input = Convert.ToInt64(Console.ReadLine().Trim());
            return input;
        }

        static long[] GetLongInputsFromLine()
        {
            var inputs = Console.ReadLine().Split(' ').Select(x => Convert.ToInt64(x.Trim())).ToArray();
            return inputs;
        }

        static double GetDoubleInputFromLine()
        {
            var input = Convert.ToDouble(Console.ReadLine().Trim());
            return input;
        }

        static double[] GetDoubleInputsFromLine()
        {
            var inputs = Console.ReadLine().Split(' ').Select(x => Convert.ToDouble(x.Trim())).ToArray();
            return inputs;
        }

        static string GetStringInputFromLine()
        {
            var input = Console.ReadLine();
            return input;
        }

        static string[] GetStringInputsFromLine()
        {
            var inputs = Console.ReadLine().Split(' ');
            return inputs;
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {

        static void Main()
        {
            string s = Console.ReadLine();
            char[] c = new char[s.Length];
            int [] x = new int[s.Length];
            for (int i = 0; i < s.Length; i++)
            {
                c[i] = Convert.ToChar(s[i]);
                x[i] = Convert.ToInt32(s[i]);
            }
            if (s.Length >= 2) // для строки больше 1 символа
            {
                if ((x[0] <= 90) & (x[1] <= 90))  // для HTTP
                {
                    c[0] = s[0];
                    for (int i = 1; i < s.Length; i++)
                        c[i] = Convert.ToChar(x[i] + 32);
                }
                if (x[0] >= 97)  // для hELLO
                {
                    int count = 0;
                    for (int i = 1; i < s.Length; i++)
                    {
                        if (x[i] <= 90)
                            count++;
                    }
                    if (count == s.Length - 1)
                    {
                        c[0] = Convert.ToChar(x[0] - 32);
                        for (int i = 1; i < s.Length; i++)
                        {
                            c[i] = Convert.ToChar(x[i] + 32);
                        }
                    }
                }
            }
            else  // для строки в 1 символ
            {
                if (x[0] >= 97)
                    c[0] = Convert.ToChar(x[0] - 32);
            }

            string str2 = new string(c);
            Console.WriteLine(c);
        }
    }
}

using System;
using System.Linq;
using System.Collections.Generic;
namespace tren
{
    class Program
    {
        static void Main(string[] args)
        {
            string word = Console.ReadLine();
            if (Char.IsLower(word[0]))
            {
                word = word.ToLower();
                Console.WriteLine(Char.ToUpper(word[0]));
                for(int i = 1; i < word.Length; i++)
                {
                    Console.Write(word[i]);
                }
            }
            else if (Char.IsUpper(word[0]) && Char.IsLower(word[1]))
            {
                word = word;
            }
            else word = word.ToLower();
            Console.WriteLine(word);
        }
    }
}

using System;
class Caps
{
		static void Main()
		{
				string input = Console.ReadLine();
				string comp = input.ToLower();
				int count = 0;
				for(int i = 0; i < input.Length; i++)
				{
						if(input[i] == comp[i])
							count++;
				}
				if(count>1)
					Console.WriteLine(input);
				else
				{
					string result = "";
					for(int i = 0; i < input.Length; i++)
					{
							string tmp = comp[i].ToString();
							if(i==0)
							result+=tmp.ToUpper();
							else
							result+=tmp;
					}
					Console.WriteLine(result);
				}
		}
}

using System;

namespace _131A
{
    class Program
    {
        static void Reverse(string txt)
        {
            for(int i = 0; i < txt.Length; i++)
            {
                if (char.IsLower(txt[i])) //если буква строчная, то
                {
                    Console.Write(char.ToUpper(txt[i]));
                }
                else //или же
                {
                    Console.Write(char.ToLower(txt[i]));
                }
            }
        }
        static void Main(string[] args)
        {
            string txt = Console.ReadLine();
            if(txt.Length > 1)
            {
                if (txt.ToUpper() == txt) //если вся строка в прописных буквах
                {
                    Reverse(txt);
                }
                else
                {
                    if (char.IsLower(txt[0]) && char.IsUpper(txt[1]) && txt.TrimStart(txt[0]) == txt.TrimStart(txt[0]).ToUpper()) //если первая буква строчная, а вторая прописная и в оставшейся части нет строчных букв
                    {
                        Reverse(txt);
                    }
                    else
                    {
                        Console.Write(txt); //если всё в исходном положении, то
                    }
                }
            }
            else
            {
                Console.Write(txt.ToUpper());
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication73
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            char ss = ' ';
            s = s.ToUpper();
            for (int i = 0; i < 1; i++)
            {
                ss = s[i];
                s = s.Remove(i, 1);
                s = s.ToLower();
            }
            Console.WriteLine(ss+s);
        }
    }
}

using System;
using System.Linq;
using System.Collections.Generic;
namespace tren
{
    class Program
    {
        static void Main(string[] args)
        {
            string word = Console.ReadLine();
            if (word.Skip(1).All(Char.IsUpper))
            {
                for (int i = 0; i < word.Length; i++)
                {
                    if (Char.IsUpper(word[i])) Console.Write(Char.ToLower(word[i]));
                    else Console.WriteLine(word[i]);
                }
            } else Console.Write(word);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace codeforces2
{
    class Program
    {
        static void Main(string[] args)
        {
            string p = Console.ReadLine();
            char[] result = new char[p.Length];
            if (p[0] > 90)
            {
                result[0] = (char)(p[0] - 32);
            } else
            {
                result[0] = p[0];
            }
            for(int i = 1; i < p.Length; i++)
            {
                if(p[1] < 91)
                {
                    result[i] = (char)(p[i] + 32);
                }
                else
                {
                    result[i] = p[i];
                }
            }
            Console.Write(result);
            Console.ReadLine();
        }
    }
}

using System;
class Test
{
    static void Main()
    {
        string sTmp = Console.ReadLine();
        string [] aTmp = sTmp.Split();
        string ans = "";
        for (int i = 0 ; i<aTmp.Length ; i++){
            int j = 0;
            foreach(char c in aTmp[i]){
                if(j == 0){
                    if(i == 0){
                        ans += Char.ToUpper(c);
                    } else {
                        ans += Char.ToLower(c);
                    }
                } else {
                    ans += Char.ToLower(c);
                }
                j++;
            }
            if(aTmp.Length != 1 && i != (aTmp.Length-1)){
                ans += " ";
            }
        }
        Console.WriteLine(ans);
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    static class upperclassbool
    {
        static public bool IsAllUpper(string input)
        {
            for (int i = 0; i < input.Length; i++)
            {
                //  Console.Write(input[i]);
                if (Char.IsLetter(input[i]) && Char.IsUpper(input[i]))

                    return true;
            }

            return false;
        }

    }

    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            var builder = new StringBuilder();

            if (char.IsLower(s[0]))
            {

                for (int i = 0; i < s.Length; i++)
                {

                    if (char.IsLower(s[i]))
                    {
                        char newword = char.ToUpper(s[i]);
                        builder.Append(newword);
                    }

                    if (char.IsUpper(s[i]))
                    {
                        char newword = char.ToLower(s[i]);
                        builder.Append(newword);
                    }
                }

            }

            else if (upperclassbool.IsAllUpper(s))
            {
                Console.Write(s.ToLower());

            }
            else
            {
                builder.Append(s);
            }

            Console.Write(builder);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _131A_CapsLock
{
    static class Program
    {
        public static bool IsAllUppercase(this string str, int start)
        {
            int i = 0;
            for (i = start; i < str.Length; i++)
            {
                if (str[i] >= 'a' && str[i] <= 'z') return false;
            }
            return true;
        }

        static void PrintAllLowercase(this string str, int start)
        {
            int i = 0;
            char ch;
            for (i = start; i < str.Length; i++)
            {
                Console.Write(char.ToLower(str[i]));
            }
            Console.Write("\n");
        }
        static void Main(string[] args)
        {
            int i = 0;
            string str = Console.ReadLine();
            char ch;

            if (str.Length==1)
            {
                if (str[0] >= 'a' && str[0] <= 'z')
                {
                    ch = char.ToUpper(str[0]);
                    Console.WriteLine(ch);
                }
                else
                {
                    Console.WriteLine(str);
                }

            }

            else if (str.IsAllUppercase(0))
            {
                Console.Write(str[0]);
                str.PrintAllLowercase(1);
            }

            else if (str[0] >= 'a' && str[0] <= 'z' && str.IsAllUppercase(1))
            {
                ch = char.ToUpper(str[0]);
                Console.Write(ch);
                str.PrintAllLowercase(1);
            }
            else
            {
                Console.WriteLine(str);
            }
        }
    }
}

using System;

namespace CF10Caps
{
    class Program
    {
        static void Main(string[] args)
        {
            string b = "";
            string a = Console.ReadLine();
            for(int i=0;i<a.Length;i++)
            {
                if(i==0)
                {
                    b += char.ToUpper(a[i]);
                }
                else
                {
                    b += char.ToLower(a[i]);
                }
            }
            Console.WriteLine(b);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace cAPSLOCK
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            char a;
            if (str[0]>=97 && str[0]<=122)
            {
                str = str.ToLower();
                a = (char)(str[0] - 32);
                Console.Write(a);
                for (int i = 1; i < str.Length; i++)
                    Console.Write(str[i]);
                return;
            }
            if (str[1] >= 65 && str[1] <= 90)
            {
                str = str.ToLower();
            }
            Console.Write(str);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CapsLock
{
    class Program
    {
        static void Main(string[] args)
        {
            string word = Console.ReadLine();
            string fixedWord = word.Substring(0, 1).ToUpper() + word.Substring(1).ToLower();

            Console.WriteLine(fixedWord);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _131A___cAPS_lOCK
{
    class Program
    {
        static void Main(string[] args)
        {
            string ip = Console.ReadLine();
            bool check = true;
            string op = string.Empty;
            for (int i = 1; i < ip.Count(); i++)
            {
                if (char.IsLower(ip[i]) == true)
                {
                    check = false;
                }
            }
            if (check == true)
            {
                ip = ip.ToLower();
                string firstchar = ip[0].ToString();
                firstchar = firstchar.ToUpper();
                ip = ip.Remove(0, 1);
                op = firstchar + ip;
            }
            else
            {
                op = ip;
            }
            Console.WriteLine(op);
            Console.ReadLine();
        }
    }
}

using System;

namespace CodeForce1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            bool flag = false;
            if (char.IsLower(s[0]))
            {
                for (int i = 1; i < s.Length; i++)
                {
                    if (char.IsLower(s[i]))
                    {
                        flag = true;
                        break;
                    }
                }
            }
            if (!flag)
            {
                s = s.ToLower();
                string result = s[0].ToString().ToUpper();
                result += s.Remove(0, 1);
                Console.WriteLine(result);
            }
            else
            {
                Console.WriteLine(s);
            }

            //Console.Read();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace YOLO
{
    class Program
    {
        static void Main(string[] args)
        {
            string x;
            x = Console.ReadLine();
            for(int i=0; i<x.Length; i++){
                if(i==0){
                    Console.Write(Char.ToUpper(x[i]));
                }
                else{
                    Console.Write(Char.ToLower(x[i]));
                }
            }
        }
    }
}

using System;

public class Test
{
	public static void Main()
	{
		string input = Console.ReadLine();

		string output = RebuildString(input);

		Console.WriteLine(output);
	}

	public static string RebuildString(string a)
	{
		string a2 = a;

		int prop = 0;

		for(int x=0;x<a.Length;x++){
			if(a[x]+""==a[x].ToString().ToUpper()){
				prop++;
			}
		}

		if(prop==a.Length){
			a2 = "";
			a2+=a[0].ToString().ToUpper();

			for(int x=1;x<a.Length;x++){
				a2+=a[x].ToString().ToLower();
			}
		}else{
			if(prop==a.Length-1 && a[0]+""!=a[0].ToString().ToLower()){
				a2 = "";
				a2+=a[0].ToString().ToUpper();

				for(int x=1;x<a.Length;x++){
					a2+=a[x].ToString().ToLower();
				}
			}
		}

		return a2;
	}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication15
{
    class Program
    {
        static void Main(string[] args)
        {
            char []ch = Console.ReadLine().ToCharArray();

            for (int i = 1; i < ch.Length; i++)
            {
                if (Char.IsUpper(ch[i]))
                    ch[i] = Char.ToLower(ch[i]);
                if(Char.IsLower(ch[i]))
                    ch[i] = ch[i];
            }
            ch[0] = Char.ToUpper(ch[0]);
            Console.WriteLine(ch);
            Console.ReadLine();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Text;

public class Program
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();

        if (s == s.ToUpper() && s.Length > 1)
        {
            Console.WriteLine(convert(s));
            return;
        }

        char[] c = s.ToUpper().ToCharArray();
        c[0] = c[0].ToString().ToLower()[0];
        string ss = new string(c);

        if ((s == ss) & (s.Length > 1))
        {
            Console.WriteLine(convert(s));
            return;
        }

        Console.WriteLine(s);
    }

    static string convert(string s)
    {

        s = s.ToLower();
        char[] c = s.ToCharArray();
        c[0] = c[0].ToString().ToUpper()[0];

        return new string(c);
    }
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Test
{
    class Program
    {
        class OlimpiadTaskC
        {
            static void Main(string[] args)
            {
                string line = Console.ReadLine();
                bool lower = false;
                for (int i = 1; i < line.Length; i++)
                {
                    if (char.IsLower(line[i]))
                    {
                        lower = true;
                        break;
                    }
                }
                if(char.IsLower(line[0]) && !lower)
                {
                    line = line.ToLower();
                    line = line.Substring(0, 1).ToUpper() + line.Remove(0, 1);
                    Console.WriteLine(line);
                    return;
                }
                if (char.IsLower(line[0]) && !false)
                {
                    line = line.ToLower();
                    Console.WriteLine(line);
                    return;
                }
                Console.WriteLine(line);
            }
        }
    }
}

using System;

namespace dev
{
    class Program
    {
        static void Main(string[] args)
        {
            string word = Console.ReadLine();

            char[] checkWordArray = new char[word.Length - 1];
            word.CopyTo(1, checkWordArray, 0, word.Length - 1);
            string checkWord = new string(checkWordArray);

            char[] newWord = new char[word.Length];

            if ((Char.IsLower(word[0]) && checkWord == checkWord.ToUpper()) || word == word.ToUpper())
            {
                foreach(char letter in word)
                {
                    if (Char.IsUpper(letter))
                    {
                        newWord[word.IndexOf(letter)] = Char.ToLower(letter);
                    }
                    else
                    {
                        newWord[word.IndexOf(letter)] = Char.ToUpper(letter);
                    }
                }
                Console.WriteLine(newWord);
            }
            else
            {
                Console.WriteLine(word);
            }

        }
    }
}

using System;
using System.Collections.Generic;

namespace test
{
    class Program
    {

        static void Main(string[] args)
        {
            string number = Console.ReadLine();
//             string[] splitchar = new string[] { " " };
//             Int32 num = Convert.ToInt32(number);

            if (number.Length > 1)
            {
                for (int i = 1; i < number.Length; i++)
                {
                    if (!char.IsUpper(number[i]))
                    {
                        Console.WriteLine(number);
                        return;
                    }
                }

                string first = number.Substring(0, 1).ToUpper();
                string other = number.Substring(1).ToLower();
                string result1 = first + other;
                Console.WriteLine(result1);
            }
            else
            {
                Console.WriteLine(number.ToUpper());
            }

        }
    }
}

using System;
using System.Collections;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            String str = Console.ReadLine();
            String res = "";
            if (check(str) == true)
            {
                for (int i = 0; i < str.Length; i++)
                {
                    char c = str[i];
                    if (i == 0)
                    {
                        c = str.ToUpper()[0];
                        res += c;
                    }
                    else
                    {
                        res += Char.ToLower(c);
                    }
                }
                Console.WriteLine(res);
            }

            else
            {
                Console.WriteLine(str);
            }

        }
        private static bool check(String s)
        {
            bool res = false;

            int l = 0;
            int u = 0;

            if (s.Equals(s.ToUpper()))
            {
                res = true;

            }

            else if ((s[0] == Char.ToLower(s[0])))
            {
                l++;
                for (int i = 1; i < s.Length; i++)
                {
                    if (s[i] == Char.ToUpper(s[i]))
                    {
                        u++;
                    }

                    else if (s[i] == Char.ToLower(s[i]))
                    {
                        l++;
                    }
                }
            }

            if (l > 1 && u > 1)
            {
                res = false;
            }

            else
            {
                res = true;
            }
            return res;
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _131A
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            if (char.ToLower(s[0]) + s.Substring(1).ToUpper() == s) Console.WriteLine(char.ToUpper(s[0]) + s.Substring(1).ToLower());
            else
            {
                Console.WriteLine(s);
            }
            Console.Read();
        }
    }
}

using System;

/// <summary>
/// Capslock.
/// </summary>
class CapsLock
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().ToCharArray();

        bool isInvalid = true;
        if (input.Length == 1)
        {
            if (char.IsLower(input[0]))
                isInvalid = false;
        }
        else
        {
            for (int i = 1; i < input.Length; i++)
            {
                if (char.IsLower(input[i]))
                {
                    isInvalid = false;
                    break;
                }
            }
        }

        if (isInvalid)
        {
            input[0] = char.IsUpper(input[0]) ? char.ToLowerInvariant(input[0]) : char.ToUpperInvariant(input[0]);
            for (int i = 1; i < input.Length; i++)
                input[i] = char.ToLowerInvariant(input[i]);
        }

        Console.WriteLine(input);
        //Console.ReadKey();
    }
}

using System;
using System.Linq;
using System.Collections;

namespace CSharpOlympTasks
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            bool change = s.Length == 1 || s.Substring(1)
                                        .All(c => Char.IsUpper(c));

            s = String.Join(string.Empty, s.Select(c => char.IsUpper(c) ? char.ToLower(c) : char.ToUpper(c)));

            Console.WriteLine(s);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace task131A
{
    class Program
    {
        static string Answer(string str)
        {
            Dictionary<char, char> d1 = new Dictionary<char, char>();
            string temp = str.ToLower();
            for (char i = 'a'; i <= 'z'; i++)
            {
                d1.Add(i, (char)((int)i - 32));
            }
            short k = 0;
            for (Int32 i = 0; i < str.Length; i++)
            {
                if (d1.ContainsKey(str[i]))
                {
                    k++;
                }
            }
            if (k > 1) return str;
            return d1[temp[0]] + temp.Substring(1);
        }
        static void Main(string[] args)
        {
            string temp = Console.ReadLine();
            Console.WriteLine(Answer(temp));
           //Console.ReadLine();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lv1Phase1
{
    class Program
    {
        static void Main(string[] args)
        {
            string m =Console.ReadLine();
            //correct word
            if (char.IsUpper(m[0]) && char.IsLower(m[1]))
                Console.WriteLine(m);
            //all caps word
            else if (allupper_(m))
            {
              string  m1 = tooutput(m);
                Console.WriteLine(m1);
            }
            //all caps but the 1st letter
            else if (isupper_(m))
            {
                string m1 = tooutput(m);
                Console.WriteLine(m1);
            }

        }

        static string tooutput(string  s)
        {
            StringBuilder k = new StringBuilder();

            for (int c = 0; c < s.Length; c++)
            {
                if (c != 0) { k.Append(char.ToLower(s[c])); }
                else { k.Append(char.ToUpper(s[c])); }

            }
            return k.ToString();
        }
       static bool allupper_ (string s)
        {

            foreach (char c in s)
            {
                if (!char.IsUpper(c)) { return false; }

            }
            return true;
        }
        static bool isupper_ (string s)
        {
            int i = 0;
            foreach (char c in s)
            {
                if (i != 0)
                {
                    if (!char.IsUpper(c)) { return false; }
                }
                i++;
            }
            return true;
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            string str;
            char ch;
            string str2;
            StringBuilder strbld = new StringBuilder();
            str = Console.ReadLine();
            ch = str[0];
            str2 = str.Substring(1, str.Length - 1);
            if (str.ToUpper() == str)
                Console.WriteLine(str.ToLower());
            else if (ch.ToString().ToLower() == ch.ToString() && str2.ToUpper() == str2)
            {
                ch = char.ToUpper(ch);
                str2 = str2.ToLower();
                strbld.Append(ch).Append(str2);
                Console.WriteLine(strbld.ToString());
            }
            else if ((ch.ToString().ToUpper() == ch.ToString() && str2.ToLower() == str2)||str.ToLower()==str) {
                Console.WriteLine(str);
            }
        }
    }
}