1. 

/**
* FWP, Ausgew√¤hlte Probleme aus dem ACM Programming Contest, SS10
* Problem: 11659 - Informants
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=78&page=show_problem&problem=2706
*
* @author Evgeni Pavlidis
* @version 1.0, 06/02/2010
*
* Method : Ad hoc
* Status : Accepted
* Runtime: 0.352
*/

import java.io.*;
import java.util.*;

class Main {

public static void main(String...args)
{
Scanner sc = new Scanner(System.in);
int i,a, x,y;
while(true)
{
i = sc.nextInt();
a = sc.nextInt();
if( a == 0 && i == 0)
break;

boolean[] reliable = new boolean[i+1];
for(int p = 1; p <= i; p++)
reliable[p] = true;


for(int ans = 0; ans < a; ans++)
{
x = sc.nextInt();
y = sc.nextInt();

if( y < 0)
reliable[-y] = false;
}

int c = 0;
for(int p = 1; p <= i; p++)
if(reliable[p])
c++;

System.out.println(c);
}
}
}


2.

/**
* FWP, Ausgew√¤hlte Probleme aus dem ACM Programming Contest, SS10
* Problem: 11659 - Informants
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=78&page=show_problem&problem=2706
*
* @author Siegfried Ippisch
* @version 1.0, 09/06/2010
*
* Method : Ad hoc
* Status : Accepted
* Runtime: 0.396
*/

import java.util.Scanner;

public class Main {

public static void main(String[] args){
Scanner input = new Scanner(System.in);

while(true){

int count = input.nextInt();
int answers = input.nextInt();

// informants Array, on start all are reliable
boolean[] informants = new boolean[count+1];
for(int i=1; i<=count; i++)
informants[i] = true;

// number of answers
if(answers == 0 && count == 0)
break;

// if informant reliable -> change state of other informant
for(int i=0; i<answers; i++){
int x = input.nextInt();
int y = input.nextInt();
if(y<0)
informants[-y] = false;
}

// count all reliable informants
int c = 0;
for(int i=1; i<=count; i++)
if(informants[i])
c++;

System.out.println(c);
}
input.close();
}

}