#include #include #include #include #define rep(i,n) for(int i=0; i<(int)(n); i++) using namespace std; using LL = long long; const int M = 100000000; int main(){ int N; cin >> N; assert(1 <= N and N <= 9); vector a(N), b(N), p(N); rep(i,N) cin >> a[i]; rep(i,N) assert(1 <= a[i] and a[i] <= M); rep(i,N) cin >> b[i]; rep(i,N) assert(1 <= b[i] and b[i] <= M); rep(i,N) p[i] = i; vector score; do{ int total = 0; rep(i,N){ int A = a[p[i]], B = b[i]; int point = max(A - B, 0); total += point; } score.push_back(total); }while(next_permutation(p.begin(),p.end())); sort(score.begin(),score.end(),greater()); int max_score = score[0]; int ans = 0; rep(i,score.size()){ if(score[i] == max_score) ans++; else break; } cout << ans << endl; return 0; }