public class test { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = Integer.valueOf(in.nextLine().trim()); if (n == 1) { System.out.println(1); return; } String[] a=in.nextLine().split(" "); String[] b=in.nextLine().split(" "); HashSet set = new HashSet<>(); String[][] dpa = new String[n][n]; String[][] dpb = new String[n][n]; for (int i = 0; i for (int j = 0; j if (i==0){ dpa[i][j]=a[j]; dpb[i][j]=b[j]; }else { dpa[i][j]=dpa[i-1][j]+dpa[0][i+j]; dpb[i][j]=dpb[i-1][j]+dpb[0][i+j]; } set.add(dpa[i][j]); set.add(dpb[i][j]); } } System.out.println(set.size()); }}