#include using namespace std; const double pi = 3.14159265358979; #define int long long int #define db double #define ldb long double #define P pair #define F first #define S second #define dtor(deg) (((deg)/360)*2*pi) #define rtod(rad) (((rad)/2/pi)*360) #define all(a) a.begin(),a.end() #define Srep(n) for(int i = 0; i < n; i++) #define Lrep(i,a,n) for(int i = a; i < n; i++) #define Brep1st(n) for(int bit = 0; bit < (1 << n); bit++) #define Brep2nd(n) Srep(n) if(bit >> i & 1) #define rep2d(n,m) Srep(n) Lrep(j,0,m) #define vi vector #define vvi vector #define vc vector #define vvc vector int32_t main(){ int n, cnt = 0, ans = 0; cin >> n; vi a(n), b(n), v(n); Srep(n) cin >> a[i]; Srep(n) cin >> b[i]; Srep(n) v[i] = i; do{ int temp = 0; Srep(n) if(a[v[i]] > b[i]) temp += a[v[i]] - b[i]; if(cnt < temp){ cnt = temp; ans = 1; }else if(cnt == temp) ans++; }while(next_permutation(all(v))); cout << ans << endl; }