/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 *//*
 package lunch;
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 *
 * @author cteam061
 */
public class Lunch {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] line;
        while ((line = br.readLine().split(" ")) != null) {

            if(line[0].compareTo("0") == 0 && line[1].compareTo("0") == 0 
                    && line[2].compareTo("0") == 0 && line[3].compareTo("0") == 0 && line[4].compareTo("0") == 0)return;
            
            int upperLimit = Integer.parseInt(line[0]);
            int soups = Integer.parseInt(line[1]);
            int mainLunch = Integer.parseInt(line[2]);
            int desert = Integer.parseInt(line[3]);
            int beverage = Integer.parseInt(line[4]);

            String[] soupsLine = br.readLine().split(" ");
            String[] mainLine = br.readLine().split(" ");
            String[] desertLine = br.readLine().split(" ");
            String[] beverageLine = br.readLine().split(" ");

            int numberOfLunches = 0;

            for (int i = 0; i < soups; i++) {
                int soupPrice = Integer.parseInt(soupsLine[i]);

                for (int j = 0; j < mainLunch; j++) {
                    int mainPrice = Integer.parseInt(mainLine[j]);

                    for (int k = 0; k < desert; k++) {
                        int desertPrice = Integer.parseInt(desertLine[k]);

                        for (int l = 0; l < beverage; l++) {
                            int beveragePrice = Integer.parseInt(beverageLine[l]);

                            if (soupPrice + mainPrice + desertPrice + beveragePrice <= upperLimit) {
                                numberOfLunches++;
                            }

                        }
                    }
                }
            }

            System.out.println(numberOfLunches);
            br.readLine();
        }
    }

}