func_code_string: #include <bits/stdc++.h>   using namespace std;   long long N;   vector<int> E[100000];   bool visit[100000] = {0};   long long component[100000] = {0};   int cN = 0;   stack<int> stk;   void DFS(int s) {     if (visit[s]) return;     visit[s] = true;     stk.push(s);     while (!stk.empty()) {       int v = stk.top();       stk.pop();       component[cN]++;       for (int i = (0); i < (E[v].size()); i++) {         if (visit[E[v][i]]) continue;         visit[E[v][i]] = true;         stk.push(E[v][i]);       }     }     cN++;   }   int main() {     cin >> N;     for (int i = (0); i < (N - 1); i++) {       int a, b;       char w[20];       scanf( %d%d%s , &a, &b, w);       bool islucky = 1;       int len = strlen(w);       for (int i = (0); i < (len); i++) {         if (w[i] ==  4  || w[i] ==  7 )           ;         else           islucky = 0;       }       if (islucky) continue;       E[a - 1].push_back(b - 1);       E[b - 1].push_back(a - 1);     }     for (int i = (0); i < (N); i++) DFS(i);     long long ret = 0;     for (int i = (0); i < (cN); i++) {       ret += component[i] * (N - component[i]) * (N - component[i] - 1);     }     cout << ret << endl;   }   