import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

void main() {
    auto S = readln.chomp;
    auto T = readln.split.array;

    foreach (t; T) {
        if (S[0] == t[0] || S[1] == t[1]) {
            writeln("YES");
            return;
        }
    }

    writeln("NO");
}
