#include <stdio.h> struct node { int r; int c; int f; }; int main() { struct node path[600], temp; int r, c, step, i, j, n, total; n = 0; while(scanf("%d%d" , &r, &c)) { if(r == -1 && c == -1) { break; } else if(r == 0 && c == 0) { for(i = 0; i < n-1; i++) { for(j = 0; j < n-i-1; j++) {if(path[j].r > path[j+1].r || (path[j].r == path[j+1].r && path[j].c > path[j+1].c)) { temp = path[j]; path[j] = path[j+1]; path[j+1] = temp; }} } step = 0; total = 0; while(total < n) {i = 0;while(i < n && path[i].f) { i++;}temp = path[i];path[i].f= 1;total += 1;step++;for(i = i+1; i < n; i++) { if(!path[i].f) { if(temp.r == path[i].r) { path[i].f = 1; temp = path[i]; total += 1; } else if(temp.r < path[i].r) { if(path[i].c >= temp.c) { path[i].f = 1; temp = path[i]; total += 1; } } }} } printf("%dn", step); n = 0; } else { path[n].r = r; path[n].f = 0; path[n++].c = c; } } return 0; }