#include <fstream>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <algorithm>
#include <cassert>

using namespace std;

const int maxN = 1000;
const int maxLen = 200;

string getName( string s )
{
  return s.substr(0, find(s.begin(), s.end(), '.') - s.begin());
}

struct tree
{
  bool isFile;
  map <string, tree *> ch;

  tree(): isFile(false) {}
  void insert( vector <string> &s, int i = 0 )
  {
    if (i == (int)s.size())
      isFile = true;
    else
    {
      if (!ch.count(s[i]))
        ch[s[i]] = new tree();
      ch[s[i]]->insert(s, i + 1);
    }
  }
  bool isTestsDir()
  {
    if (isFile)
      return false;
    vector <int> tst;
    vector <int> ans;
    for (map <string, tree *>::iterator it =
      ch.begin(); it != ch.end(); it++)
      if (it->second->isFile)
      {
        string t = it->first;
        if (t.length() == 2)
        {
          if (!isdigit(t[0]) || !isdigit(t[1]))
            return false;
          tst.push_back(atoi(t.c_str()));
        }
        else if (t.length() == 4)
        {
          if (!isdigit(t[0]) || !isdigit(t[1]) || t[2] != '.' || t[3] != 'a')
            return false;
          ans.push_back(atoi(t.c_str()));
        }
        else
          return false;
      }
    if (tst.size() != ans.size())
      return false;
    int n = tst.size();
    if (n < 1 || n > 99)
      return false;
    sort(tst.begin(), tst.end());
    sort(ans.begin(), ans.end());
    for (int i = 0; i < n; i++)
      if (tst[i] != i + 1 || ans[i] != i + 1)
        return false;
    return true;
  }
  bool isProblem()
  {
    bool hasCheck = false, hasTests = false;
    for (map <string, tree *>::iterator it =
      ch.begin(); it != ch.end(); it++)
      if (it->second->isFile && getName(it->first) == "check")
        hasCheck = true;
      else if (it->second->isTestsDir())
        hasTests = true;
    return hasCheck && hasTests;
  }
  bool isContest()
  {
    int cnt = 0;
    for (map <string, tree *>::iterator it =
      ch.begin(); it != ch.end(); it++)
      if (it->second->isProblem())
        cnt++;
    return cnt > 0 && cnt == (int)ch.size();
  }
  int count()
  {
    int ans = (int)isContest();
    for (map <string, tree *>::iterator it =
      ch.begin(); it != ch.end(); it++)
        ans += it->second->count();
    return ans;
  }
};

char toLower( char c )
{
  if ('A' <= c && c <= 'Z') c += 'a' - 'A';
  return c;
}

vector <string> split( string t, char c )
{
  vector <string> res;
  string cur;
  for (int i = 0; i < (int)t.length(); i++)
    if (t[i] == c)
      res.push_back(cur), cur = "";
    else
      cur += toLower(t[i]);
  if (cur.length() > 0)
    res.push_back(cur);
  return res;
}

int main()
{
  int n;
  ifstream in("contests.in");
  assert(in >> n);
  assert(1 <= n && n <= maxN);
  tree root;
  for (int i = 0; i < n; i++)
  {
    string t;
    assert(in >> t);
    assert(1 <= t.length() && t.length() <= maxLen);
    vector <string> z = split(t, '\\');
    root.insert(z);
  }
  in.close();

  int ans = root.count();
  ofstream out("contests.out");
  out << ans << endl;
  out.close();
  return 0;
}
