#include using namespace std; using Int = int_fast64_t; using Word = uint_fast64_t; using VInt = vector; using VVI = vector; using VWord = vector; using VVW = vector; using VS = vector; using VVS = vector; using VB = vector; using VVB = vector; using PII = pair; using PWW = pair; using VPII = vector; using VPWW = vector; #define SZ(x) ((Int)(x).size()) #define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) #define rep(i,n) for(Int i=0, i##_len=(n); i> n; VInt a(n), b(n), c(n); rep(i,n) cin >> a[i]; rep(i,n) cin >> b[i]; rep(i,n) c[i] = i; Int ans = 0; Int res = -1; do { Int s = 0; rep(i,n) s += max(0L, a[c[i]] - b[i]); if (s > res) { res = s; ans = 0; } if (s == res) ans++; } while (next_permutation(ALL(c))); cout << ans << '\n'; return 0; }