#include using namespace std; #define rep(i, a, b) for (int i = a; i < b; i++) using ll = long long; struct point { ll x, y; }; bool is_upper(point &p) { if(p.y > 0) return true; if(p.y == 0 && p.x > 0) return true; return false; } bool comp_ang(point &a, point &b) { bool ua = is_upper(a); bool ub = is_upper(b); if(ua != ub) { return ua > ub; } ll cross = a.x * b.y - a.y * b.x; return cross > 0; } int main(){ vector s(3); cin >> s[0] >> s[1] >> s[2]; vector> vst(3); vector sz(3); rep(i, 0, 3) sz[i] = s[i].size(); rep(i, 0, 3) { rep(j, 1, sz[i] + 1) { vst[i].insert(s[i].substr(0, j)); } } using ST = vector; set st; for(auto e1 : vst[0]) { for(auto e2 : vst[1]) { for(auto e3 : vst[2]) { ST w; w.push_back(e1); w.push_back(e2); w.push_back(e3); sort(w.begin(), w.end()); st.insert(w); } } } ll ans = 0; for(auto e: st) { set w; vector v(3); rep(i, 0, 3) v[i] = i; do { string t; rep(i, 0, 3) t += e[v[i]]; w.insert(t); } while(next_permutation(v.begin(), v.end())); ans += w.size(); } cout << ans << endl; }