#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

int maxcnt;
bool vis[100];
int graph_lens[100];
int graph[100][100];

void search(int i, int cnt, int ub) {
  if(maxcnt<cnt) maxcnt=cnt;
  vis[i] = true;
  int len = graph_lens[i];
  int *edg = graph[i];
  ub++;
  for(int j = 0; j < len; j++) {
    if(!vis[edg[j]])ub--;
  }
  if(maxcnt < ub) {
    cnt++;
    for(int j = 0; j < len; j++) {
      int to = edg[j];
      if(!vis[to]) search(to, cnt, ub);
    }
  }
  vis[i] = false;
}

int main() {
  while(true) {
    int n; scanf("%d", &n);
    if(n==0) break;
    fill(vis, vis+100, false);
    fill(graph_lens, graph_lens+100, 0);
    for(int i = 0; i < n; i++) {
      int a,b; scanf("%d%d", &a, &b); a--; b--;
      graph[a][graph_lens[a]++] = b;
      graph[b][graph_lens[b]++] = a;
    }
    maxcnt = 0;
    for(int i = 0; i < 100; i++) {
      search(i,1,n+1);
    }
    printf("%d\n", maxcnt);
  }
  return 0;
}