import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;

void main ()
{
	string s;
	while ((s = readln.strip) != "")
	{
		auto t = readln.split;
		bool ok = t.any !(r => r[0] == s[0] || r[1] == s[1]);
		writeln (ok ? "YES" : "NO");
	}
}
