func_code_string: #include <bits/stdc++.h>   using namespace std;   struct node {     string name;     vector<struct node *> sub;   };   typedef struct node *NODE;   class cf56c {    public:     int ans = 0;     void solve(std::istream &in, std::ostream &out) {       string s;       int n;       in >> s;       n = s.length();       stack<struct node *> stk;       int p = 0;       string word;       while (s[p] >=  A  && s[p] <=  Z ) {         word += s[p];         p++;       }       NODE root = new struct node;       root->name = word;       stk.push(root);       while (p < n) {         string t;         NODE latest = stk.top();         if (s[p] ==  ,  || s[p] ==  : ) {           p++;           while (s[p] >=  A  && s[p] <=  Z  && p < n) {             t += s[p];             p++;           }           NODE child = new struct node;           child->name = t;           latest->sub.push_back(child);           stk.push(child);         }         if (s[p] ==  . ) {           stk.pop();           p++;         }       }       unordered_map<string, int> visited;       dfs(root, visited);       out << ans;     }     void dfs(NODE root, unordered_map<string, int> visited) {       string employee = root->name;       vector<NODE> children = root->sub;       ans += visited[employee];       visited[employee]++;       for (auto &i : children) {         dfs(i, visited);       }     }   };   int main() {     ios_base::sync_with_stdio(false);     cf56c solver;     std::istream &in(std::cin);     std::ostream &out(std::cout);     solver.solve(in, out);     return 0;   }   