#ifdef NACHIA #define _GLIBCXX_DEBUG #else // disable assert #define NDEBUG #endif #include #include #include #include using namespace std; using ll = long long; const ll INF = 1ll << 60; #define REP(i,n) for(ll i=0; i using V = vector; template void chmax(A& l, const B& r){ if(l < r) l = r; } template void chmin(A& l, const B& r){ if(r < l) l = r; } void testcase(){ string X, Y, Z; cin >> X >> Y >> Z; V A; REP(i,X.size()+1) REP(j,Y.size()+1) REP(k,Z.size()+1) if(i && j && k){ auto x = X.substr(0, i); auto y = Y.substr(0, j); auto z = Z.substr(0, k); A.push_back(x + y + z); A.push_back(x + z + y); A.push_back(y + x + z); A.push_back(y + z + x); A.push_back(z + x + y); A.push_back(z + y + x); } sort(A.begin(), A.end()); ll ans = A.size(); REP(i,A.size()-1) if(A[i] == A[i+1]) ans--; cout << ans << "\n"; } int main(){ cin.tie(0)->sync_with_stdio(0); testcase(); return 0; }