Gennady owns a small hotel in the countryside where he lives a peaceful life. He loves to take long walks, watch sunsets and play cards with tourists staying in his hotel. His favorite game is called "Mau-Mau".To play Mau-Mau, you need a pack of $$$52$$$ cards. Each card has a suit (Diamonds — D, Clubs — C, Spades — S, or Hearts — H), and a rank (2, 3, 4, 5, 6, 7, 8, 9, T, J, Q, K, or A).At the start of the game, there is one card on the table and you have five cards in your hand. You can play a card from your hand if and only if it has the same rank or the same suit as the card on the table.In order to check if you'd be a good playing partner, Gennady has prepared a task for you. Given the card on the table and five cards in your hand, check if you can play at least one card.

The first line of the input contains one string which describes the card on the table. The second line contains five strings which describe the cards in your hand. Each string is two characters long. The first character denotes the rank and belongs to the set $$$\{{\tt 2}, {\tt 3}, {\tt 4}, {\tt 5}, {\tt 6}, {\tt 7}, {\tt 8}, {\tt 9}, {\tt T}, {\tt J}, {\tt Q}, {\tt K}, {\tt A}\}$$$. The second character denotes the suit and belongs to the set $$$\{{\tt D}, {\tt C}, {\tt S}, {\tt H}\}$$$. All the cards in the input are different.

If it is possible to play a card from your hand, print one word "YES". Otherwise, print "NO". You can print each letter in any case (upper or lower).

NoteIn the first example, there is an Ace of Spades (AS) on the table. You can play an Ace of Diamonds (AD) because both of them are Aces.In the second example, you cannot play any card.In the third example, you can play an Ace of Diamonds (AD) because it has the same suit as a Four of Diamonds (4D), which lies on the table.

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

namespace ConsoleApp18
{
    class Program
    {
        static void Main(string[] args)
        {
            string tableCard = Console.ReadLine();
            string[] handCard = Console.ReadLine().Split(' ');
            bool canPlay = false;

            foreach(string hC in handCard)
            {
                if(tableCard[0] == hC[0] || tableCard[1] == hC[1])
                {
                    canPlay = true;
                    break;
                }
            }
            Console.WriteLine(canPlay ? "YES" : "NO");
        }
    }
}

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

namespace Codeforces
{
	class Program
	{
		static void Main(string[] args)
		{
			var card = Console.ReadLine();
			var cards = Console.ReadLine().Split(' ');
			for (int i = 0; i < cards.Length; i++)
			{
				if (cards[i][0] == card[0] || cards[i][1] == card[1])
				{
					Console.WriteLine("YES");
					return;
				}
			}
			Console.WriteLine("NO");
		}

		static int Int()
		{
			return Int32.Parse(Console.ReadLine());
		}

		static (int, int) Int2()
		{
			var arr = Array.ConvertAll(Console.ReadLine().Split(' '), Int32.Parse);
			return (arr[0], arr[1]);
		}

		static (int, int, int) Int3()
		{
			var arr = Array.ConvertAll(Console.ReadLine().Split(' '), Int32.Parse);
			return (arr[0], arr[1], arr[2]);
		}

		static int[] Ints()
		{
			return Array.ConvertAll(Console.ReadLine().Split(' '), Int32.Parse);
		}

	}

}

using System;

class Program
{
    static void Main()
    {
        string main = Console.ReadLine();
        string hand = Console.ReadLine();

        Console.WriteLine((hand.Contains(main[0].ToString()) || hand.Contains(main[1].ToString())) ? "YES" : "NO");
    }
}

using System;
using System.Linq;

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

            string inTable = Console.ReadLine();
            string hands = Console.ReadLine();
            bool can = false;

            string[] inHands = hands.Split(' ');

            for (int i = 0; i < inHands.Length;i++)
            {
                if(can) break;
                for (int j = 0; j < 2;j++)
                {
                    if (inHands[i][j] == inTable[0] || inHands[i][j] == inTable[1])
                    {
                        can = true;
                    }
                }

            }

            Console.WriteLine(can ? "YES" : "NO");
        }

    }
}

using System;

namespace CF_1097_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string cTable = Console.ReadLine();
            string[] myCards = Console.ReadLine().Split();

            foreach(string card in myCards)
            {
                if(card[0] == cTable[0] ||
                    card[1] == cTable[1])
                {
                    Console.WriteLine("YES");
                    return;
                }
            }
            Console.WriteLine("NO");
        }
    }
}

using System;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;

        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }

            var res = line[index];
            index++;
            return res;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public ulong NextUlong()
        {
            return ulong.Parse(Next());
        }

        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }

        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }

        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    class Program
    {
        private string card;
        private string[] myCard;
        void Scan()
        {
            var sc = new Scanner();
            card = sc.Next();
            myCard = sc.Array();
        }

        public void Solve()
        {
            Scan();
            foreach (var s in myCard)
            {
                if (card[0] == s[0] || card[1] == s[1])
                {
                    Console.WriteLine("YES");
                    return;
                }

            }
            Console.WriteLine("NO");
        }

        static void Main() => new Program().Solve();
    }

}

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

namespace A.Геннадий_и_карточная_игра
{
    class Program
    {
        static void Main(string[] args)
        {
            string card = Console.ReadLine();
            string[] sleeve = Console.ReadLine().Split(' ');

            string res = "NO";

            for (int i = 0; i < sleeve.Length; i++)
            {
                if (card[0] == sleeve[i][0])
                {
                    res = "YES";
                    break;
                }
                if (card[1] == sleeve[i][1])
                {
                    res = "YES";
                    break;
                }
            }

            Console.WriteLine(res);
        }
    }
}

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

namespace Algorithms01
{
    class Program
    {
        static void Main(string[] args)
        {
            ParseSolveWrite();
        }

        public static void ParseSolveWrite()
        {
            var (cardOnDeck, cardsInHand) = Parse();
            var result = Solve(cardOnDeck, cardsInHand);
            Write(result);
        }

        private static (Card, List<Card>) Parse()
        {
            var input = Console.ReadLine();
            var cardOnDeck = new Card
            {
                Rank = input.Substring(0, 1),
                Suit = input.Substring(1, 1)
            };
            input = Console.ReadLine();
            var cardsInHand = input
                .Split(new char[] { ' ' })
                .Select((value) =>
                    new Card
                    {
                        Rank = value.Substring(0, 1),
                        Suit = value.Substring(1, 1)
                    }
                )
                .ToList();
            return (cardOnDeck, cardsInHand);
        }

        private static string Solve(Card cardOnDeck, List<Card> cardsInHand)
        {
            foreach (var card in cardsInHand)
            {
                if (isSameRank(card, cardOnDeck) || isBiggerSameSuit(card, cardOnDeck))
                    return "YES";
            }
            return "NO";
        }

        private static bool isBiggerSameSuit(Card card, Card cardOnDeck)
        {
            return card.Suit == cardOnDeck.Suit;
        }

        private static bool isSameRank(Card card, Card cardOnDeck)
        {
            return card.Rank == cardOnDeck.Rank;
        }

        private static void Write(string result)
        {
            Console.WriteLine(result);
        }

        class Card
        {
            public string Rank { get; set; }

            public string Suit { get; set; }
        }
    }
}

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

namespace CodeForces
{
    class Program
    {
        static void Main(string[] args)
        {
            var ta = Console.ReadLine();
            var ha = Console.ReadLine();
            // var ins = ha.Split(" ");
            // var li = ins.Select(n => Convert.ToInt32(n)).ToList();

            if (ha.Contains(ta[0]) || ha.Contains(ta[1]))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }

            // Console.Write($"{a.ToString()} {b.ToString()} {c.ToString()}");

        }
    }
}

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

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var l = Console.ReadLine().Split();
            for (var i = 0; i < l.Length; i++)
            {
                if (l[i][0] == s[0] || l[i][1] == s[1])
                {
                    Console.WriteLine("YES");
                    //Console.ReadKey();
                    return;
                }
            }

            Console.WriteLine("NO");
            //Console.ReadKey();
        }
    }
}

using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string tableCard = Console.ReadLine();
            string[] handCards = Console.ReadLine().Split();

            for (int i = 0; i < handCards.Length; i++)
            {
                if (handCards[i][0] == tableCard[0] || handCards[i][1] == tableCard[1])
                {
                    Console.WriteLine("YES");
                    return;
                }
            }

            Console.WriteLine("NO");
        }
    }
}

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

namespace x
{
    class Program
    {
        static void Main(string[] args)
        {
            //��������� ������ ��� �����
            string kard = Console.ReadLine();

            //��������� ���� ������
            string deck = Console.ReadLine();

            //��������� ���������� ��� �������� 1 ����� �� ����� ����������
            string temp;

            //������ ��� �������� ������
            string[] deckARR;

            //���������� ������� �������
            deckARR = deck.Split(' ');
            //��������� ��� �������� ���������� ����������
            bool comp = false;

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

                //*����� ������� ������
                //Console.Write(deckARR[i] + " ");

                //��������� ������ �� ������ � ������ ������ �� 1 �������
                temp = deckARR[i];
                if (temp[0] == kard[0])
                    comp = true;
                else if (temp[1] == kard[1])
                    comp = true;
            }

            if (comp == true)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");

            //Console.ReadKey();
        }
    }
}

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

namespace DevskillProblems
{
    class Program
    {
        static void Main(string[] args)
        {
            string s1 = Console.ReadLine();
            string s2 = Console.ReadLine();
            var str = s2.Split(" ");
            bool flag = false;

            for (int i = 0; i < str.Length; i++)
            {
                if (str[i].Contains(s1[0]) || str[i].Contains(s1[1]))
                {
                    flag = true;
                }
            }
            if (flag)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }
}

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

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

            string s = ReadLine();
            string[] a = ReadLine().Split(' ');

            WriteLine(card(s, a) ? "YES" : "NO");
            Read();
        }

        private static bool card(string s, string[] a)
        {
            for (int i = 0; i < 5; i++)
            {
                if (s[0] == a[i][0] || s[1] == a[i][1])
                {
                    return true;
                }
            }

            return false;
        }

    }
}

using System;
    sealed class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var ss = Console.ReadLine();
            Console.WriteLine(ss.Contains(s[0].ToString()) || ss.Contains(s[1].ToString()) ? "YES" : "NO");
        }
    }

using System;

namespace _1097A
{
    class Program
    {
        static void Main(string[] args)
        {
            String baseCard = Console.ReadLine();
            string count = baseCard.Substring(0, 1);
            string colour = baseCard.Substring(1, 1);
            string[] cards = Console.ReadLine().Split(' ');
            bool result = false;
            for (int i = 0; i < cards.Length; i++)
            {
                string curCard = cards[i];
                string curCount = curCard.Substring(0, 1);
                string curColour = curCard.Substring(1, 1);
                if ((curColour == colour) || (curCount == count))
                {
                    result = true;
                    i = cards.Length;
                }
            }
            if (result) Console.WriteLine("YES");
            else Console.WriteLine("NO");
        }
    }
}

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

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            // input //
            string str = Console.ReadLine();
            string[] cards = Console.ReadLine().Split();

            // process //
            bool c = false;
            foreach(string card in cards)
                if (card[0] == str[0] || card[1] == str[1])
                {
                    c = true;
                    break;
                }

            // output //
            if (!c)
                Console.Write("NO");
            else
                Console.Write("YES");

            Console.Read();
        }
    }
}

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

namespace _1097A_GennadyAndACardGame
{
    class Program
    {
        static void Main(string[] args)
        {
            string result = "NO";
            var input = Console.ReadLine().ToCharArray();
            string[] tokens = Console.ReadLine().Split();
            for(int i = 0; i< tokens.Length; i++)
            {
                if (tokens[i][0].Equals(input[0]) || tokens[i][1].Equals(input[1]))
                {
                    result = "YES";
                    break;
                }
            }
            Console.WriteLine(result);
            Console.ReadLine();
        }
    }
}

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

namespace _1097A
{
    class Program
    {
        static void Main(string[] args)
        {
            string cart = Console.ReadLine();
            string hands = Console.ReadLine();
            string[] carthand = hands.Split(' ');
            int kolvo = carthand.Length;
            bool m=false;
            for (int i = 0; i < kolvo; i++)
            {
                if ((carthand[i][0] == cart[0])||(carthand[i][1] == cart[1]))
                {
                    m = true;
                }
            }
            if (m) { Console.WriteLine("YES"); } else { Console.WriteLine("NO");}
        }
    }
}

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

namespace Gennady_and_a_Card_Game
{
    class Program
    {
        static void Main(string[] args)
        {
            string table = Console.ReadLine();
            string[] tokens = Console.ReadLine().Split();
            string first = tokens[0];
            string second = tokens[1];
            string third = tokens[2];
            string fourth = tokens[3];
            string fifth = tokens[4];
            if(table[0] == first[0] || table[0] == second[0] || table[0] == third[0] || table[0] == fourth[0] || table[0] == fifth[0] || table[1] == first[1] || table[1] == second[1] || table[1] == third[1] || table[1] == fourth[1] || table[1] == fifth[1])
            {
                Console.WriteLine("YES");
            } else {
                Console.WriteLine("NO");
            }
            Console.WriteLine();
        }
    }
}

using System;
namespace SortApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            string first = str[0].ToString();
            string second = str[1].ToString();
            string word = Console.ReadLine();
            int f = 0;
            int s = 0;
            for(int i = 0; i < word.Length; i=i+3)
            {
                if (first == word[i].ToString())
                {
                    f = 1;
                }

            }
            for (int i = 1; i < word.Length; i = i + 3)
            {
                if (second == word[i].ToString())
                {
                    s = 1;
                }

            }
            if(s==1 || f == 1)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }

            //Console.WriteLine();
            Console.Read();

        }
    }
}

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

namespace Elephant
{
    class Program
    {
        static void Main(string[] args)
        {
            string oneCard = Console.ReadLine();
            string tableCard = Console.ReadLine();
            if(tableCard.Contains(oneCard[0]) || tableCard.Contains(oneCard[1]))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

using System;
using System.Collections.Generic;

class Program
    {

        static void Main(string[] args)
        {

            String tkarta = Console.ReadLine();
            String mykarts = Console.ReadLine();

                if (mykarts.Contains( Convert.ToString(tkarta[0])) || mykarts.Contains( Convert.ToString(tkarta[1])))
                {
                    Console.WriteLine("YES");
                }else{ Console.WriteLine("NO"); }

            Console.ReadLine();
        }

    }

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

namespace CodeFroces
{
    class Program
    {
        static void Main(string[] args)
        {
            string Floor_Card = Console.ReadLine();
            string Mine_Cards = Console.ReadLine();
            if (Mine_Cards.Contains(Floor_Card[0]) || Mine_Cards.Contains(Floor_Card[1]))
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");

        }
    }
}

using System;

class MainClass {
  public static void Main (string[] args) {
    string onTheTable = Console.ReadLine();
    char[] onTT = new char[2];
    onTT[0] = Convert.ToChar(onTheTable.Substring(0, 1));
    onTT[1] = Convert.ToChar(onTheTable.Substring(1, 1));

    string[] inYourHand = Console.ReadLine().Split(' ');
    char[][] inYH = new char[5][];

    for (int i = 0; i < 5; i++) {
        inYH[i] = new char[2];
        inYH[i][0] = Convert.ToChar(inYourHand[i].Substring(0, 1));
        inYH[i][1] = Convert.ToChar(inYourHand[i].Substring(1, 1));
    }
    bool YorN = false;
    foreach (char[] c in inYH) {
        if (onTT[0] == c[0] || onTT[1] == c[1]) {
            YorN = true;
            Console.WriteLine("Yes");
            break;
        }
    }
    if (YorN == false) {
        Console.WriteLine("No");
    }
  }
}

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

namespace CSharpTuto
{
   class Program
    {
        static void Main()
        {
            string table_card = Console.ReadLine();
            char[] table_card_char = table_card.ToCharArray();
            string[] cards_in_hand = Console.ReadLine().Split(' ');
            bool can_play = false;
            char[] result = null;
            foreach (string card in cards_in_hand)
            {
                char[] hand_card = card.ToCharArray();
                result = hand_card.Intersect(table_card_char).ToArray();
                if (result.Length != 0)
                {
                    can_play = true;
                    break;
                }
            }
            if(can_play)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string table = Console.ReadLine();
            string[]  myCards = Console.ReadLine().Split(' ');

            for (int i = 0; i < myCards.Length; i++)
            {
                if (myCards[i].ToCharArray()[0] == table[0] || myCards[i].ToCharArray()[1] == table[1])
                {
                    Console.WriteLine("YES");
                    return;
                }
            }

            Console.WriteLine("NO");
        }
    }
}

using System;

namespace _200501_GennadyAndACardGame
{
    class Program
    {
        static void Main(string[] args)
        {
            string table = Console.ReadLine();
            string[] hand = Console.ReadLine().Split(' ');

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

                if (hand[i].Contains(table[0].ToString()) || hand[i].Contains(table[1].ToString()))
                {
                    Console.WriteLine("YES");
                    return;
                }

            }

            Console.WriteLine("NO");

        }
    }
}

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

namespace Gennady_and_a_Card_Game
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            string arr = Console.ReadLine();
            char[] input1 = input.ToCharArray();
            char[] arr1 = arr.ToCharArray();
            bool p = true;
            for (int i = 0; i < input1.Length; i++)
            {
                for (int i1 = 0; i1 < arr1.Length; i1++)
                {
                    if (input1[i] == arr1[i1])
                    {
                        p = false;
                    }
                }
            }
            if (p == false)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

using System;
class Codeforce1097A
{
  static void Main()
  {
      string k = Console.ReadLine();
      string s = Console.ReadLine();
      for(int i=0; i<s.Length; i++)
      {
          if(s[i]==k[0] || s[i]==k[1])
          {
          Console.Write("YES");
          break;
          }
          else if(i==s.Length-1)
          Console.Write("NO");
      }

  }
}

using System;

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

            int flag = 0;

            for(int i=0; i<input.Length; i++)
            {
                if(values.Contains(input[i].ToString()))
                {
                    flag = 1;
                    break;
                }
            }

            if(flag == 1)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;

namespace Code
{
    class Program
    {
        static void Main(string[] args)
        {
            string tableCard = Console.ReadLine();
            string[] myCards = Console.ReadLine().Split(' ');

            foreach(string s in myCards)
            {
                if (s[0] == tableCard[0] || s[1] == tableCard[1])
                {
                    Console.WriteLine("YES");
                    return;
                }
            }
            Console.WriteLine("NO");
        }
    }
}

using System;

namespace CodeForces
{
    class Program
    {
        static void Main(string[] args)
        {
            string maincard = Console.ReadLine();
            string othercards = Console.ReadLine();
            bool yes = false;
            for (int i = 0; i < 14; i++)
            {
                if (othercards[i] == 32)
                {

                }
                else if (i % 3 == 0)
                {
                    if (othercards[i] == maincard[0])
                    {
                        Console.WriteLine("YES");
                        yes = true;
                        break;
                    }

                }
                else if ((i % 3)-1 == 0) {
                    if (true)
                    {
                        if (othercards[i] == maincard[1])
                        {
                            Console.WriteLine("YES");
                            yes = true;
                            break;
                        }
                    }

                }
            }

            if (yes == false)
            {
                Console.WriteLine("NO");
            }

        }
    }
}

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

namespace Code
{
    class Program
    {
        static void Main(string[] args)
        {
            string t = Console.ReadLine();
            string s = Console.ReadLine();
            string[] h = s.Split(' ');
            int count = 0;

            for(int i=0;i<=4;i++)
            {
                if (t.Substring(0, 1) == h[i].Substring(0, 1) || t.Substring(1, 1) == h[i].Substring(1, 1))
                    count++;
            }
            if (count >= 1)
                Console.WriteLine("YES");
            else Console.WriteLine("NO");
            Console.ReadLine();
        }
    }
}

using System;

namespace CF_1097A_GennadyAndACardGame
{
    class Program
    {
        static void Main(string[] args)
        {
            var cardOnTheTable = Console.ReadLine();
            var cardsInHand = (Console.ReadLine()).Split(' ');

            var possible = false;

            for(var i = 0; i < 5; i++)
            {
                if(cardsInHand[i][0] == cardOnTheTable[0] || cardsInHand[i][1] == cardOnTheTable[1])
                {
                    possible = true;
                    break;
                }
            }

            if(possible)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }
}

using System;
namespace ConsoleApplication38
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string[] m = Console.ReadLine().Split();
            for (int i = 0; i < m.Length; ++i)
            {
                if (s[0] == m[i][0] || s[1] == m[i][1])
                {
                    Console.WriteLine("YES");
                    return;
                }
            }
            Console.WriteLine("NO");
        }
    }
}

using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
public class Test
{

	public static void Main()
	{
		string str = Console.ReadLine();
		string[] array = Array.ConvertAll(Console.ReadLine().Split(' '), a => a.ToString());
		List<string> cardslist = new List<string>(array);
		string sonuc = "NO";
		for (int i = 0; i < array.Length; i++)
		{
			if (cardslist[i].Contains(str[0]) || cardslist[i].Contains(str[1]))
			{
				sonuc = "YES";
				break;
			}
		}
		Console.WriteLine(sonuc);
	}
}

using System;
class Codeforces1097A_VlCikl
{
  static void Main()
  {
    string k = Console.ReadLine();
    string s = Console.ReadLine();
    int flag = 0;
    for (int j=0; j<k.Length; j++)
    {
        for (int i=0; i<s.Length; i++)
        {
         if(s[i]==k[j])
         {
         flag = 1;
         j=k.Length;
         break;
         }
        }
    }
    Console.Write(flag==1?"YES":"NO");
  }
}

using System;

class Program
{
    static void Main()
    {
        string main = Console.ReadLine();
        string hand = Console.ReadLine();

        Console.WriteLine((hand.Contains(main[0].ToString()) || hand.Contains(main[1].ToString())) ? "YES" : "NO");
    }
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string card = Console.ReadLine();
            string[] hand = Console.ReadLine().Split(' ');
            bool check = false;
            for (int i = 0; i <= 4; i++)
                if (hand[i][0] == card[0] || hand[i][1] == card[1])
                {
                    Console.WriteLine("YES");
                    check = true;
                    break;
                }
            if (check == false)
                Console.WriteLine("NO");
        }
    }
}

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

namespace Gennady_and_a_Card_Game
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            writer.WriteLine(Solve(args) ? "Yes" : "No");
            writer.Flush();
        }

        private static bool Solve(string[] args)
        {
            string n = reader.ReadLine();
            string k = reader.ReadLine();

            return k.Contains(n[0]) || k.Contains(n[1]);
        }
    }
}

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

namespace test1
{
    class Program
    {
        static void Main(string[] args)
        {
                char p = Convert.ToChar(Console.Read()),q=Convert.ToChar(Console.ReadLine());
            //Console.Write("{0} {1}",p,q);
            string s = Console.ReadLine();
            if (Length(s,q,p)) Console.Write("YES");
            else Console.Write("NO");
           // Console.ReadKey();
        }
        static bool Length(string s,char p,char q)
        {
            int a = 0;
            foreach (int x in s)
                if (x == p || x == q) { return true; }
            return false;
            //return ;
        }
    }
}

using System;

namespace Runner
{
    class Program
    {
        static void Main(string[] args)
        {
            string cardOnTable = Console.ReadLine();
            string[] cardsInHand = Console.ReadLine().Split(new char[] { ' ' });

            for (int i = 0; i < cardsInHand.Length; i++)
            {
                char rank = cardsInHand[i][0];
                char suit = cardsInHand[i][1];

                if (rank == cardOnTable[0] || suit == cardOnTable[1])
                {
                    Console.WriteLine("YES");
                    return;
                }
            }

            Console.WriteLine("NO");
        }
    }
}

using System;

namespace Game
{
    class Program
    {
        static void Main(string[] args)
        {
            string onTable = Console.ReadLine();
            string[] cards = Console.ReadLine().Split();
            bool flag = false;
            foreach(var card in cards)
            {
                if(card[0] == onTable[0] || card[1] == onTable[1])
                {
                    flag = true;
                    break;
                }
            }
            Console.WriteLine(flag ? "YES" : "NO");
            //Console.ReadKey();
        }
    }
}

using System;

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

            string str1 = Console.ReadLine();

            string str2 = Console.ReadLine();

            if (str2.Contains(str1[1])||str2.Contains(str1[0]))
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");

        }
    }
}

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

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

            input = Console.ReadLine();
            var setCard = input.Split();

            var isCan = false;
            for (int i = 0; i < setCard.Length; i++)
            {
                if (setCard[i][0] == card[0] || setCard[i][1] == card[1])
                {
                    isCan = true;
                    break;
                }
            }

            if (isCan)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

using System;
public class Program
{
    public static void Main() {
        string s  = Console.ReadLine();

        string[] h = Console.ReadLine().Split();

        for(int i = 0; i <5; i++){
            if(s[0] == h[i][0] || s[1] == h[i][1]){
                Console.WriteLine("YES");
                return;
            }
        }
        Console.WriteLine("NO");

  }
}

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

namespace GennadyAndACardGame
{
	class Program
	{
		static void Main(string[] args)
		{
			string s = Console.ReadLine();
			string s2 = Console.ReadLine();
			string[] s1 = s2.Split(' ');
			int leng = s1.Length;
			string ans = "NO";
			for (int i = 0; i < leng; i++)
			{
				if (s[0] == s1[i][0] || s[1] == s1[i][1])
				{
					ans = "YES";
					i = leng;
				}
			}
			Console.WriteLine(ans);
		}
	}
}

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

namespace codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            var tableCard = Console.ReadLine();
            var cards = Console.ReadLine().Split(' ');

            var result = "no";

            for (var i = 0; i < 2; i++)
            {
                for (var j = 0; j < cards.Length; j++)
                {
                    if (tableCard[i] == cards[j][i])
                    {
                        result = "yes";
                        break;
                    }
                }
            }
            System.Console.WriteLine(result);

        }
    }
}

using System;
using System.Collections.Generic;

namespace CodeForces
{

    class Parser {

        public static int ReadIntFromStdin() {
            int prev = ' '; int res = 0;
            int symb = Console.Read();
            while ((symb < '0') || (symb > '9')) {
                prev = symb;
                symb = Console.Read();
            }
            while ((symb >= '0') && (symb <= '9')) {
                res = 10 * res + symb - '0';
                symb = Console.Read();
            }
            if (prev == '-') { return -res; }
            else { return res; }
        }

        public static List<int> ReadIntsFromStdin(int n) {
            List<int> res = new List<int>(); int cnt = 0;
            while(cnt < n) {
                res.Add(ReadIntFromStdin());
                cnt++;
            }
            return res;
        }

        public static int ConvertStringToInt(string str) {
            int res = 0; int start = 0; int sign = 1;
            if (str[0] == '-') { start = 1; sign = -1;}
            for (int i = start; i < str.Length; i++) {
                res = 10 * res + sign * (str[i] - '0');
            }
            return res;
        }

        public static List<string> SplitStringBasedOnDelim(string str, char delim) {
            List<string> res = new List<string>(); string buf = "";
            for (int i = 0; i < str.Length; i++) {
                if (str[i] != delim) { buf = buf + str[i]; }
                else { if (buf != "") { res.Add(buf); buf = ""; } }
            }
            if (buf != "") { res.Add(buf); }
            return res;
        }

    }

    class Vertex {

        public int name;
        public int value;
        public int _in;
        public int _out;
        public List<Vertex> descendants;

        public Vertex(int name, int value) {
            this.name = name;
            this.value = value;
            this._in = 0;
            this._out = 0;
            this.descendants = new List<Vertex>();
        }

        private bool isInDescendants(Vertex v) {
            bool flag = false;
            foreach (Vertex i in descendants) {
                if (i.name == v.name) { flag = true; break; }
            }
            return flag;
        }

        public void AddDescendant(Vertex v) {
            if (! isInDescendants(v)) {
                descendants.Add(v);
            }
        }

    }

    class Edge {
        public Edge() {

        }
    }

    class Graph {

        private Vertex root;
        private List<Vertex> vertices;

        public Graph() {
            root = null;
            vertices = new List<Vertex>();
        }

        public void AddVertex(Vertex v) {

        }

        public void PrintRoot() {
            System.Console.WriteLine("{0}", root.name);
        }

        public void PrintAllVertices() {
            foreach (Vertex v in vertices) {
                System.Console.WriteLine("{0}", v.name);
            }
        }

    }

    class BinaryHeap {

        private Vertex[] heap;

        public BinaryHeap(int n) {
            this.heap = new Vertex[n+1];
        }

        public void PrintHeap() {
            foreach (Vertex v in heap) {
                System.Console.WriteLine("{0}", v.name);
            }
        }

    }

    class Program {
        static void Main(string[] args) {
            string t = System.Console.ReadLine();
            List<string> ml = Parser.SplitStringBasedOnDelim(
                                     System.Console.ReadLine(), ' ');
            bool flag = false;
            foreach (string s in ml) {
                if (s[0] == t[0] || s[1] == t[1]) {
                    flag = true;
                    break;
                }
            }
            if (flag == true) {
                System.Console.WriteLine("YES");
            }
            else {
                System.Console.WriteLine("NO");
            }
        }
    }
}

using System;

class Program
{
    static void Main(string[] args)
    {
        string table = Console.ReadLine();
        string[] hand = Console.ReadLine().Split();
        string ans = "NO";
        for (int i = 0; i < 5; i++) {
            if (hand[i][0] == table[0] || (hand[i][1] == table[1]))
                ans = "YES";
        }
        Console.WriteLine(ans);
    }

}

using System;
using System.Collections.Generic;

class Program
    {

        static void Main(string[] args)
        {

            String tkarta = Console.ReadLine();
            String mykarts = Console.ReadLine();

                if (mykarts.Contains( Convert.ToString(tkarta[0])) || mykarts.Contains( Convert.ToString(tkarta[1])))
                {
                    Console.WriteLine("YES");
                }else{ Console.WriteLine("NO"); }

            Console.ReadLine();
        }

    }

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 str = Console.ReadLine();
            string[] str1 = Console.ReadLine().Split();
            bool flag = false;
            for (int i = 0; i < str1.Length; i++)
            {
                string p = str1[i];
                if ((str[0] == p[0]) || (str[0] == p[1]) || (str[1] == p[0]) || (str[1] == p[1]))
                    flag = true;
            }
            if(flag)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }
}

using System;
class Codeforces1097A_VlCikl
{
  static void Main()
  {
    string k = Console.ReadLine();
    string s = Console.ReadLine();
    int flag = 0;
    for (int j=0; j<k.Length; j++)
    {
        for (int i=0; i<s.Length; i++)
        {
         if(s[i]==k[j])
         {
         flag = 1;
         j=k.Length;
         break;
         }
        }
    }
    Console.Write(flag==1?"YES":"NO");
  }
}

using System;

namespace Gennady_and_a_Card_Game
{
    class Program
    {
        static void Main(string[] args)
        {
            string cardOnTable = Console.ReadLine();
            string[] cardsOnHand = Console.ReadLine().Split();

            bool flag = false;
            foreach (string card in cardsOnHand)
            {
                if ((card[0] == cardOnTable[0]) || card[1] == cardOnTable[1])
                {
                    Console.WriteLine("YES");
                    flag = true;
                    break;
                }
            }

            if (flag == false)
                Console.WriteLine("NO");
        }
    }
}

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

namespace DevskillProblemSolving
{
    class Program
    {
        static void Main(string[] args)
        {
            string cardOnTable = Console.ReadLine();
            List<string> cardOnHand = Console.ReadLine().Split(' ').ToList();

            bool canPlay = false;

            foreach (var card in cardOnHand)
            {
                if (card[0].ToString().Equals(cardOnTable[0].ToString()) || card[1].ToString().Equals(cardOnTable[1].ToString()))
                {
                    canPlay = true;
                    break;
                }
            }

            if(canPlay)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }
}

using System;
using System.Linq;

namespace TestConsole
{
    public class Program
    {
        static void Main(string[] args)
        {
            var tableCard = Console.ReadLine();
            var handCards = Console.ReadLine().Split(' ');

            var result = handCards.Count(c => c[0] == tableCard[0] || c[1] == tableCard[1]) > 0;

            Console.WriteLine(result ? "YES" : "NO");
        }
    }
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s=Console.ReadLine();
            string s1 = Console.ReadLine();
            int n = 5;
            bool p=false;
            for (int i = 0; i < s1.Length; i++)
                if ((s1[i] == s[0]) || (s1[i] == s[1]))
                { Console.WriteLine("YES"); p = true; break; }
            if (!p) Console.WriteLine("NO");
        }
    }
}

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

namespace nolab
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] d;
            int count=0;
            int count1=0;

         string q = Console.ReadLine();

            var chunkSize = 1;
             var k = (from Match m in Regex.Matches(q, @".{1," + chunkSize + "}")
                          select m.Value).ToList();
            string[] five = Console.ReadLine().Split(new Char[] { ' ' });
            var u = (from Match m in Regex.Matches(five[0], @".{1," + chunkSize + "}")
                     select m.Value).ToList();

            for (int i=0;i<=4;i++)
            {

                u = (from Match m in Regex.Matches(five[i], @".{1," + chunkSize + "}")
                         select m.Value).ToList();
                count = k[0].Zip(u[0], (a, b) => a == b).TakeWhile(c => c).Count();
                if (count != 0)
                {
                    count1++;
                }

            }
            u = (from Match m in Regex.Matches(five[0], @".{1," + chunkSize + "}")
                     select m.Value).ToList();

            for (int i = 0; i <= 4; i++)
            {
                u = (from Match m in Regex.Matches(five[i], @".{1," + chunkSize + "}")
                     select m.Value).ToList();
                count = u[1].Zip(k[1], (a, b) => a == b).TakeWhile(c => c).Count();
                if(count!=0)
                {
                    count1++;
                }

            }

            //n = Int64.Parse(Console.ReadLine());
            if (count1 == 0)
            {
                Console.WriteLine("NO");
            }
            else
            {
                Console.WriteLine("YES");
            }
        }
    }
}

using System;
using System.Linq;

namespace _1097A
{
    public static class ReadWriteGeneric
    {
        public static T GetInputs<T>(this string inInput, char inSeparator = ' ')
        {
            if (!typeof(T).IsArray)
            {
                return (T)Convert.ChangeType(inInput, typeof(T));
            }

            var inputList = inInput.Split(inSeparator);
            var elementType = typeof(T).GetElementType();

            var array = Array.CreateInstance(elementType, inputList.Length);
            for (var i = 0; i < array.Length; i++)
            {
                array.SetValue(Convert.ChangeType(inputList[i], elementType), i);
            }

            return (T)(object)array;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            var firstCard = Console.ReadLine();
            var hand = Console.ReadLine().GetInputs<string[]>();
            Console.WriteLine(hand.Any(card => card[0] == firstCard[0] || card[1] == firstCard[1]) ? "YES" : "NO");
        }
    }
}

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

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

            if (hand.Contains(input[0]) || hand.Contains(input[1]))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
            return;
        }
    }
}

using System;

namespace Competitive
{
    class Solution
    {
        static void Main(string[] args)
        {
            string s1 = Console.ReadLine();
            char a = s1[0];
            char b = s1[1];

            string[] arr = Console.ReadLine().Split(' ');
            bool ans = false;

            foreach (string s in arr)
            {
                if (s[0] == a || s[1] == b)
                {
                    ans = true;
                    break;
                }
            }

            if (ans)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }
}

using System;
using System.Collections;
using System.Collections.Generic;
class solution
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();
        string[] cards = Console.ReadLine().Split(' ');
        bool canplay = false;
        for(int i=0;i<cards.Length;i++)
        {
            if (cards[i][0] == s[0] || cards[i][1] == s[1])
            {
                canplay = true;
                break;
            }
        }
        if (canplay) Console.Write("YES");
        else if (!canplay) Console.Write("NO");
    }
}

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 cot = Console.ReadLine();
            string[] cards = Console.ReadLine().Split(' ');
            for (int i = 0; i < cards.Length; i++)
            {
                char[] temp = cards[i].ToCharArray();
                if (temp.Contains(cot[0]) || temp.Contains(cot[1]))
                {
                    Console.WriteLine("YES");
                    return;
                }

            }

            Console.WriteLine("NO");

        }
    }
}

using System;

namespace _1097A
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            string[] str1 = new string[6];
            string[] input = (Console.ReadLine()).Split();
            for (int i = 0; i < 5; i++)
            {
                 str1[i] = (input[i]);
            }
            int temp = 0;
            for(int j=0;j<5;j++)
            {
                string st = str1[j];

                if (str[0] == st[0] || str[1]==st[1])
                    temp = 1;
                if (temp == 1)
                    break;
            }
            if (temp == 1)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }
}

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)
        {
            Int32 i;
            string ans="NO", sInput;
            string fInput=Console.ReadLine();

            sInput = Console.ReadLine();

            if ((fInput[0] == sInput[0]) || (fInput[0] == sInput[3]) || (fInput[0] == sInput[6]) || (fInput[0] == sInput[9]) || (fInput[0] == sInput[12]))
            {
                ans = "YES";
            }

            if ((fInput[1] == sInput[1]) || (fInput[1] == sInput[4]) || (fInput[1] == sInput[7]) || (fInput[1] == sInput[10]) || (fInput[1] == sInput[13]))
            {
                ans = "YES";
            }
            Console.WriteLine(ans);

        }
    }
}

using System;

namespace Game
{
    class Program
    {
        static void Main(string[] args)
        {
            string onTable = Console.ReadLine();
            string[] cards = Console.ReadLine().Split();
            bool flag = false;
            foreach(var card in cards)
            {
                if(card[0] == onTable[0] || card[1] == onTable[1])
                {
                    flag = true;
                    break;
                }
            }
            Console.WriteLine(flag ? "YES" : "NO");
            //Console.ReadKey();
        }
    }
}

using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string tableCard = Console.ReadLine();
            string[] handCards = Console.ReadLine().Split();

            for (int i = 0; i < handCards.Length; i++)
            {
                if (handCards[i][0] == tableCard[0] || handCards[i][1] == tableCard[1])
                {
                    Console.WriteLine("YES");
                    return;
                }
            }

            Console.WriteLine("NO");
        }
    }
}

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

namespace Olymp
{
  public class ProblemSolver
  {
    private Tokenizer input;

    public void Solve()
    {
      var s = input.ReadLine();
      for (var i = 0; i < 5; i++)
      {
        var a = input.ReadToken();
        if (s[0] == a[0] || s[1] == a[1])
        {
          Console.Write("YES");
          return;
        }
      }
      Console.Write("NO");
    }

    public ProblemSolver(TextReader input)
    {
      this.input = new Tokenizer(input);
    }

    #region Service functions

    private static void AddCount<T>(Dictionary<T, int> counter, T item)
    {
      if (counter.TryGetValue(item, out var count))
        counter[item] = count + 1;
      else
        counter.Add(item, 1);
    }

    private static int GetCount<T>(Dictionary<T, int> counter, T item)
    {
      return counter.TryGetValue(item, out var count) ? count : 0;
    }

    private static int GCD(int a, int b)
    {
      while (b != 0)
      {
        a %= b;
        var t = b;
        b = a;
        a = t;
      }
      return a;
    }

    #endregion
  }

  #region Service classes

  public class Tokenizer
  {
    private TextReader reader;

    public string ReadToEnd()
    {
      return this.reader.ReadToEnd();
    }

    public int ReadInt()
    {
      var c = SkipWS();
      if (c == -1)
        throw new EndOfStreamException();
      var isNegative = false;
      if (c == '-' || c == '+')
      {
        isNegative = c == '-';
        c = this.reader.Read();
        if (c == -1)
          throw new InvalidOperationException();
      }
      if (!char.IsDigit((char)c))
        throw new InvalidOperationException();
      var result = (char)c - '0';
      c = this.reader.Read();
      while (c > 0 && !char.IsWhiteSpace((char)c))
      {
        if (!char.IsDigit((char)c))
          throw new InvalidOperationException();
        result = result * 10 + (char)c - '0';
        c = this.reader.Read();
      }
      if (isNegative)
        result = -result;
      return result;
    }

    public string ReadLine()
    {
      return reader.ReadLine();
    }

    public long ReadLong()
    {
      return long.Parse(this.ReadToken());
    }

    public double ReadDouble()
    {
      return double.Parse(this.ReadToken(), CultureInfo.InvariantCulture);
    }

    public int[] ReadIntArray(int n)
    {
      var a = new int[n];
      for (var i = 0; i < n; i++)
        a[i] = ReadInt();
      return a;
    }

    public long[] ReadLongArray(int n)
    {
      var a = new long[n];
      for (var i = 0; i < n; i++)
        a[i] = ReadLong();
      return a;
    }

    public double[] ReadDoubleArray(int n)
    {
      var a = new double[n];
      for (var i = 0; i < n; i++)
        a[i] = ReadDouble();
      return a;
    }

    public string ReadToken()
    {
      var c = SkipWS();
      if (c == -1)
        return null;
      var sb = new StringBuilder();
      while (c > 0 && !char.IsWhiteSpace((char)c))
      {
        sb.Append((char)c);
        c = this.reader.Read();
      }
      return sb.ToString();
    }

    private int SkipWS()
    {
      var c = this.reader.Read();
      if (c == -1)
        return c;
      while (c > 0 && char.IsWhiteSpace((char)c))
        c = this.reader.Read();
      return c;
    }

    public Tokenizer(TextReader reader)
    {
      this.reader = reader;
    }
  }

  internal class Program
  {
    public static void Main(string[] args)
    {
      var solver = new ProblemSolver(Console.In);
      solver.Solve();
    }
  }

  #endregion
}

using System;

class Program
{
    static void Main(string[] args)
    {
        string table = Console.ReadLine();
        string[] hand = Console.ReadLine().Split();
        string ans = "NO";
        for (int i = 0; i < 5; i++) {
            if (hand[i][0] == table[0] || (hand[i][1] == table[1]))
                ans = "YES";
        }
        Console.WriteLine(ans);
    }

}

using System;
class Program
{
    static void Main()
    {
        Func<string> r = () => Console.ReadLine();
        string a = r(), s = r();
        Console.WriteLine(s.IndexOf(a[0]) >= 0 | s.IndexOf(a[1]) >= 0 ? "YES" : "NO");
    }
}

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

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

            string s2 = Console.ReadLine();

            string[] str = s2.Split(' ').ToArray();

            bool f = false;
            for( int i=0; i< str.Length; i++)
            {
                if (str[i].Contains(s1[0]) || str[i].Contains(s1[1]))
                { f = true; break; }

            }

            if (f)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }
}

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

namespace ConsoleApp27

{

    class Program

    {

        static void Main(string[] args)

        {
            String n = Console.ReadLine();

            String b = Console.ReadLine();

            for (int i = 0; i <14; i += 3)
            {
                if (b[i] == n[0])
                {
                    Console.WriteLine("YES");
                    return;
                }

            }

            for (int i = 1; i < 14; i+=3)
            {
                if(b[i]==n[1])
                {
                    Console.WriteLine("YES");
                    return;
                }

            }

            Console.WriteLine("NO");

        }

    }

}

using System;
using System.Linq;

namespace TestConsole
{
    public class Program
    {
        static void Main(string[] args)
        {
            var tableCard = Console.ReadLine();
            var handCards = Console.ReadLine().Split(' ');

            var result = handCards.Count(c => c[0] == tableCard[0] || c[1] == tableCard[1]) > 0;

            Console.WriteLine(result ? "YES" : "NO");
        }
    }
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;

namespace Code
{
    class Program
    {
        static void Main(string[] args)
        {
            string tableCard = Console.ReadLine();
            string[] myCards = Console.ReadLine().Split(' ');

            foreach(string s in myCards)
            {
                if (s[0] == tableCard[0] || s[1] == tableCard[1])
                {
                    Console.WriteLine("YES");
                    return;
                }
            }
            Console.WriteLine("NO");
        }
    }
}

using System;
class Codeforce1097A
{
  static void Main()
  {
      string k = Console.ReadLine();
      string s = Console.ReadLine();
      for(int i=0; i<s.Length; i++)
      {
          if(s[i]==k[0] || s[i]==k[1])
          {
          Console.Write("YES");
          break;
          }
          else if(i==s.Length-1)
          Console.Write("NO");
      }

  }
}

using System;
using System.IO;

namespace Issue
{
    public static class Program
    {
        public static void Main(string[] args) {
			const int cards_count = 5;

			var table_card = IO.ReadLine();
			var hand_cards = IO.ReadLine();

			var canHaveATurn = IsMatch(table_card, hand_cards, 0)
							|| IsMatch(table_card, hand_cards, 3)
							|| IsMatch(table_card, hand_cards, 6)
							|| IsMatch(table_card, hand_cards, 9)
							|| IsMatch(table_card, hand_cards, 12);

			Console.WriteLine(canHaveATurn ? "YES" : "NO");
        }

		private static bool IsMatch(string table_card, string cards, int index) {
			return table_card[0] == cards[index] || table_card[1] == cards[index + 1];
		}
    }

    public static class IO {
        public const int ZeroCode = (int) '0';

        static IO() {
            Reader = new StreamReader(
                Console.OpenStandardInput(),
                System.Text.Encoding.ASCII,
                false,
                sizeof(int),
                false);
        }

        public static StreamReader Reader {
            get; set;
        }

        public static string ReadLine() {
            return Reader.ReadLine();
        }

        public static int Read() {
            var reader = Reader;
            var symbol = reader.Read();

            while (symbol == ' ') {
                symbol = reader.Read();
            }

            var isNegative = false;
            if (symbol == '-') {
                isNegative = true;
                symbol = reader.Read();
            }

            int result = 0;
            for ( ;
                (symbol != -1) && (symbol != ' ');
                symbol = reader.Read()
            ) {
                var digit = symbol - ZeroCode;

                if (digit < 10 && digit >= 0) {
                    result = (result << 1) + ((result << 1) << 2) + digit;
                } else {
                    if (symbol == 13)         // if symbol == \n
                        reader.Read();        // skip next \r symbol
                    break;
                }
            }

            return isNegative ? ~result + 1 : result;
        }
    }

    public static class Sort {
        public static void Heapsort<T>(this T[] array, bool isReversed = false)
            where T : IComparable<T>
        {
            Func<T[], int, int, int> comparer;

            if (isReversed)
                comparer = Extensions.Min;
            else
                comparer = Extensions.Max;

            // create Heap from unordered array
            BuildHeap(array, comparer);

            // sort
            for (var i = array.Length - 1; i >= 0; --i)
            {
                Swap(ref array[0], ref array[i]);
                FloatUp(array, 0, i, comparer);
            }
        }

        private static void BuildHeap<T>(T[] array, Func<T[], int, int, int> comparer)
            where T : IComparable<T>
        {
            var size = array.Length;
            var last_index = size - 1;

            for (var i = (last_index - 1) / 2; i >= 0; --i)
            {
                FloatUp(array, i, size, comparer);
            }
        }

        private static void FloatUp<T>(T[] array, int index, int size, Func<T[], int, int, int> comparer)
            where T : IComparable<T>
        {
            var left_node_index = 2 * (index + 1) - 1;
            var right_node_index = 2 * (index + 1);

            if (left_node_index >= size)
            {
                return;
            }

            var largest = comparer(array, left_node_index, index);

            if (right_node_index < size)
            {
                largest = comparer(array, right_node_index, largest);
            }

            if (largest != index)
            {
                Swap(ref array[index], ref array[largest]);
                FloatUp(array, largest, size, comparer);
            }
        }

        private static void Swap<T>(ref T a, ref T b)
        {
            T temp = a;
            a = b;
            b = temp;
        }
    }

    public static class Extensions {
        public static int Max<T>(this T[] array, int firstIndex, int secondIndex)
            where T : IComparable<T>
        {
            return (array[firstIndex].CompareTo(array[secondIndex]) > 0)
                ? firstIndex
                : secondIndex;
        }

        public static int Min<T>(this T[] array, int firstIndex, int secondIndex)
            where T : IComparable<T>
        {
            return (array[firstIndex].CompareTo(array[secondIndex]) <= 0)
                ? firstIndex
                : secondIndex;
        }
    }
}

using System;

namespace CF_1097A_GennadyAndACardGame
{
    class Program
    {
        static void Main(string[] args)
        {
            var cardOnTheTable = Console.ReadLine();
            var cardsInHand = (Console.ReadLine()).Split(' ');

            var possible = false;

            for(var i = 0; i < 5; i++)
            {
                if(cardsInHand[i][0] == cardOnTheTable[0] || cardsInHand[i][1] == cardOnTheTable[0])
                {
                    possible = true;
                    break;
                }
            }

            if(possible)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }
}

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

namespace A.Геннадий_и_карточная_игра
{
    class Program
    {
        static void Main(string[] args)
        {
            string card = Console.ReadLine();
            string[] sleeve = Console.ReadLine().Split(' ');

            string res = "NO";

            for (int i = 0; i < sleeve.Length; i++)
            {
                if (card[0] == sleeve[i][0])
                {
                    res = "YES";
                    break;
                }
                if (card[1] == sleeve[i][0])
                {
                    res = "YES";
                    break;
                }
            }

            Console.WriteLine(res);
        }
    }
}

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

class Program
{
    public static void Main(string[] args)
    {
        //MulticaseTest();
        char r = Console.ReadLine()[0];
        char[] cards = Console.ReadLine().Split().Select(x => x[0]).ToArray();
        Console.WriteLine(cards.Contains(r) ? "YES" : "NO");
    }
    public static void MulticaseTest()
    {
        //4
        //4 5 2 3
        int t = int.Parse(Console.ReadLine());
        List<string> o = new List<string>(t);
        for (int i = 0; i < t; i++)
        {
            int n = int.Parse(Console.ReadLine());
            //List<int> input = Console.ReadLine().Split().Select(int.Parse).ToList();

        }
        o.ForEach(Console.WriteLine);
    }
}

using System;

namespace NetCore
{
    class Program
    {
        static void Main(string[] args)
        {
            string pattern = Console.ReadLine();
            string[] values = Console.ReadLine().Split(' ');
            foreach(string value in values)
            {
                if(value[0] == pattern[0] || value[1] == pattern[1] || (value[0] == 'A' || value[0] == 'K') && (pattern[0] == 'A' || pattern[0] == 'K'))
                {
                    Console.WriteLine("YES");
                    return;
                }
            }
            Console.WriteLine("NO");
        }
    }
}

using System;
using System.Collections.Generic;

namespace Problem_Solving
{
    class Program
    {
        static void Main(string[] args)
        {
            string handCard = Console.ReadLine();
            bool isPrinted = false;

            string tableCard = Console.ReadLine();
            string[] tableCards = tableCard.Split(' ');

            for (int i=0; i<5;i++)
            {
                tableCard = tableCards[i];
                if(handCard[1] == tableCard[1])
                {
                    Console.WriteLine("YES");
                    isPrinted = true;
                    break;
                }
            }

            if(!isPrinted)
                Console.WriteLine("NO");
        }
    }
}

using System;

namespace Gennady_and_a_Card_Game
{
    class Program
    {
        static void Main(string[] args)
        {
            string cardOnTable = Console.ReadLine();
            string[] cardsOnHand = Console.ReadLine().Split();

            bool flag = false;
            foreach (string card in cardsOnHand)
            {
                if ((card[0] == cardOnTable[0]) || card[1] == cardOnTable[1])
                {
                    Console.WriteLine("YES");
                    flag = true;
                }
            }

            if (flag == false)
                Console.WriteLine("NO");
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
namespace ogaver__
{

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

            var t = Console.ReadLine();

            var deck = Console.ReadLine().Split(' ');

            foreach(var s in deck)
                if(s.Contains(t[0]) || s.Contains(t[1]))
                    Console.WriteLine("YES");

            Console.WriteLine("NO");

        }

    }
}

using System;
using System.Collections.Generic;
using System.Linq;
namespace ogaver__
{

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

            var t = Console.ReadLine();

            var deck = Console.ReadLine().Split(' ');

            bool yes = false;
            foreach(var s in deck)
                if(s.Contains(t[0]) || s.Contains(t[1]))
                {
                    Console.WriteLine("YES");
                    yes = true;
                }

            if(!yes)
            Console.WriteLine("NO");

        }

    }
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s=Console.ReadLine();
            string s1 = Console.ReadLine();
            int n = 5;
            bool p=false;
            for (int i = 0; i < s1.Length; i++)
                if ((s1[i] == s[0]) || (s1[i] == s[1]))
                { Console.WriteLine("YES"); p = true; }
            if (!p) Console.WriteLine("NO");
        }
    }
}