import java.util.*; public class Main { static int n; static int[] aArr; static int[] bArr; static int max = 0; static int count = 0; public static void main(String[] args) { Scanner sc = new Scanner(System.in); n = sc.nextInt(); aArr = new int[n]; for (int i = 0; i < n; i++) { aArr[i] = sc.nextInt(); } bArr = new int[n]; for (int i = 0; i < n; i++) { bArr[i] = sc.nextInt(); } boolean[] used = new boolean[n]; int[] arr = new int[n]; setPerm(used, arr, 0); System.out.println(count); } static void setPerm(boolean[] used, int[] arr, int idx) { if (idx == n) { int value = 0; for (int i = 0; i < n; i++) { value += Math.max(0, bArr[i] - aArr[arr[i]]); } if (max < value) { max = value; count = 1; } else if (max == value) { count++; } return; } for (int i = 0; i < n; i++) { if (used[i]) { continue; } used[i] = true; arr[idx] = i; setPerm(used, arr, idx + 1); used[i] = false; } } }