/*G - Travelling Salesman Problem*/

/*F - PLUR @ EDC*/

/*A - Headphones */

#include <bits/stdc++.h>
using namespace std;

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int a, b, c;
	int ans;
	int maximo;

	cin >> a >> b >> c;

	ans = a + b + c;
	maximo = max(a, b);
	maximo = max(maximo, c);

	ans -= maximo;

	cout << ans;

	return 0;
}
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>
#include <string>
#include <set>
#include <tuple>
#include<map>

using namespace std;
int main() {
	string A, B, C;
	cin >> A >> B >> C;

	bool ans = true;

	if (A.at(A.size() - 1) != B.at(0)) ans = false;
	if (B.at(B.size() - 1) != C.at(0)) ans = false;

	if (ans) cout << "YES" << endl;
	else cout << "NO" << endl;

}