#include #include #include #include #define rep(i,n) for(int i=0; i<(int)(n); i++) using namespace std; int main(){ int N; cin >> N; assert(N>=1 && N<=10); vector a(N), b(N); rep(i,N){ int A; cin >> A; assert(A>=1 && A<=1e8); a[i]=A; } rep(i,N){ int B; cin >> B; assert(B>=1 && B<=1e8); 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; }