// The "FileIO" class.
import java.io.*;
import java.awt.*;
import hsa.Console;

public class Q2
{
    static Console c;           // The output console

    public static void main (String[] args) throws IOException
    {
	c = new Console ();
	int[] [] input = new int [5] [2];
	int[] expected = new int [5];
	String stringInput = "";
	int space;
	int score = 0;
	int count2 = 0;


	try
	{
	    FileReader fr = new FileReader ("DATA2.txt");
	    BufferedReader br = new BufferedReader (fr);

	    String line;
	    int count = 0;
	    while ((line = br.readLine ()) != null)
	    {
		//<line = something>
		if (count < 5)
		{
		    space = line.indexOf (' ');
		    for (int i = 0 ; i < space ; i++)
		    {
			stringInput += line.charAt (i);
		    }
		    input [count] [0] = Integer.parseInt (stringInput);


		    stringInput = "";

		    for (int i = space + 1 ; i < line.length () ; i++)
		    {
			stringInput += line.charAt (i);
		    }
		    input [count] [1] = Integer.parseInt (stringInput);
		    stringInput = "";
		    count++;

		}
		else
		{
		    expected [count2] = Integer.parseInt (line);
		    count2++;
		}
	    }

	    br.close ();

	    int[] sums = new int [5];

	    sums [0] = input [0] [0] + input [0] [1];

	    sums [1] = input [1] [0] + input [1] [1];
	    sums [2] = input [2] [0] + input [2] [1];
	    sums [3] = input [3] [0] + input [3] [1];
	    sums [4] = input [4] [0] + input [4] [1];

	    for (int j = 0 ; j < 5 ; j++)
	    {

		if (sums [j] == expected [j])
		    score++;

	    }

	    FileWriter fw = new FileWriter ("OUT2.txt");
	    PrintWriter pr = new PrintWriter (fw);

	    pr.println (score);



	    pr.close ();

	}
	catch (IOException e)
	{
	    c.println ("IOException");
	}
	catch (NumberFormatException e)
	{
	    c.println ("NumberFormateException");
	}

	int[] sums = new int [5];

	sums [0] = input [0] [0] + input [0] [1];
	sums [1] = input [1] [0] + input [1] [1];
	sums [2] = input [2] [0] + input [2] [1];
	sums [3] = input [3] [0] + input [3] [1];
	sums [4] = input [4] [0] + input [4] [1];

	for (int j = 0 ; j < 5 ; j++)
	{
	    if (sums [j] == expected [j])
		score++;

	}







	// Place your program here.  'c' is the output console
    } // main method
} // FileIO class

