#include <iostream>
#include <ctime>
#include <cstdlib>

using namespace std;

struct szomlistnode{
  int cel;
  char c;
  struct szomlistnode* kov;
};

struct szomlist{
 struct szomlistnode* head;
};

struct Graph{
 int v;
 struct szomlist* a;
};

struct szomlistnode* newSzomListNode(int cel, char c){

struct szomlistnode* newNode =(struct szomlistnode*) malloc(sizeof(struct szomlistnode));

newNode->cel = cel;

newNode->c = c;

newNode->kov = NULL;

return newNode;
}

void adjElet(struct Graph* graph, int kiindul, int cel, char c){


struct szomlistnode* newNode = newSzomListNode(cel,c);

newNode->kov = graph->a[kiindul].head;

graph->a[kiindul].head = newNode;



newNode = newSzomListNode(kiindul,c);

newNode->kov = graph->a[cel].head;

graph->a[cel].head = newNode;
}

struct Graph* csinaljGrafot(int V){

struct Graph* graph =(struct Graph*)malloc(sizeof(struct Graph));

graph->v = V;

graph->a=(struct szomlist*) malloc(V * sizeof(struct szomlist));

int i;

for (i = 0; i < V; ++i)

graph->a[i].head = NULL;

return graph;

}

int path(struct Graph* g, int u, int v){

    struct szomlistnode* n =g->a[u].head;


}

int main()
{
   srand((unsigned)time(NULL));
   int n, sum=0;
   cin >> n;

   struct Graph* g = csinaljGrafot(n);

   for(int i=0; i<n-1; i++){
        int u,v;
        char c;

        cin >> u >> v;
        cin >> c;
        adjElet(g,u,v,c);
   }

   sum = rand()%(n/3) +1;

    cout << sum;

    return 0;
}