#include #include #include #include #define rep(i,n) for(int i=0; i<(int)(n); i++) using namespace std; const int Max_Num=9; const int Max_Fac=1e8; int main(){ int N; cin >> N; assert(N>=1 && N<=Max_Num); vector a(N), b(N); rep(i,N){ int A; cin >> A; assert(A>=1 && A<=Max_Fac); a[i]=A; } rep(i,N){ int B; cin >> B; assert(B>=1 && B<=Max_Fac); b[i]=B; } vector p(N), point; rep(i,N) p[i]=i; do{ int res=0; rep(i,N) if(a[p[i]]>b[i]) res+=a[p[i]]-b[i]; point.emplace_back(res); }while (next_permutation(p.begin(),p.end())); sort(point.begin(),point.end(),greater()); int MAX=point[0], ans=0; rep(i,point.size()){ if(point[i]==MAX) ans++; else break; } cout << ans << endl; return 0; }