#include <stdio.h>
#include <string.h>

int main() {
	char a[11], b[11], c[11];

	scanf("%s %s %s", a, b, c);
	int l1 = strlen(a);
	int l2 = strlen(b);
	
	if(a[l1 - 1] == b[0] && b[l2 - 1] == c[0]) {
		puts("YES");
	}	
	else puts("NO");

	return 0;
}
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

using ll = long long;

int main() {
    int N, ans = 0;
    string A, B, C;
    cin >> N >> A >> B >> C;
    rep(i, N) {
        if (A[i] == B[i]) {
            if (A[i] != C[i]) ans++;
        } else if (A[i] == C[i]) {
            ans++;
        } else if (B[i] == C[i]) {
            ans++;
        } else {
            ans += 2;
        }
    }
    cout << ans << "\n";
}