#include #include using namespace std; using namespace atcoder; using ld = long double; using ll = long long; using ull = unsigned long long; using VB = vector; using VVB = vector; using VC = vector; using VVC = vector; using VI = vector; using VVI = vector; using VVVI = vector; using VL = vector; using VVL = vector; using VVVL = vector; using VD = vector; using VVD = vector; using VT = vector; using VVT = vector; using P = pair; using VP = vector

; #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define FOR(i, a, b) for (ll i = a; i < (ll)(b); i++) #define ALL(a) (a).begin(),(a).end() constexpr int INF = 1001001001; constexpr ll LINF = 1001001001001001001ll; //constexpr ll LINF = 8e18; //constexpr int DX[] = {-1, -1, 0, 0, 1, 1}; //constexpr int DY[] = {-1, 0, -1, 1, 0, 1}; constexpr int DX[] = {1, 0, -1, 0, 0, 0}; constexpr int DY[] = {0, 1, 0, -1, 0, 0}; //constexpr int DZ[] = {0, 0, 0, 0, 1, -1}; template< typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true); } template< typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true); } using mint = modint998244353; //using mint = modint1000000007; using VM = vector; using VVM = vector; using VVVM = vector; using VVVVM = vector; inline ll divceil(ll x, ll y) { if(x >= 0) return (x + y - 1) / y; else return -((-x) / y); } inline ll divfloor(ll x, ll y) { if(x >= 0) return x / y; else return -((- x + y - 1) / y); } int idx = 0; VVI e(750001, VI(26, -1)); VI c(750001, 0); void maketree(string x, int y, int z) { if (y == x.size()) { c[z] = 1; return; } int w = x[y] - 'a'; if (e[z][w] == -1) { idx++; e[z][w] = idx; } maketree(x, y + 1, e[z][w]); } int main() { ios::sync_with_stdio(false); std::cin.tie(nullptr); VT x(3); REP(i, 3) cin >> x[i]; VI n(3), p(3); REP(i, 3) { n[i] = x[i].size(); p[i] = i; //cout << "n,p=" << n[i] << " " << p[i] << endl; } do { REP(i, n[0] * n[1] * n[2]) { VI m(3); int y = i; REP(j, 3) { m[p[j]] = y % n[p[j]]; y /= n[p[j]]; } string s = ""; REP(j, 3) { s += x[p[j]].substr(0, m[p[j]] + 1); } maketree(s, 0, 0); //cout << s << " " << idx << endl; } } while (next_permutation(ALL(p))); int ans = 0; REP(i, idx + 1) ans += c[i]; cout << ans << endl; }