#include using namespace std; using ll = long long; constexpr char newl = '\n'; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; vector a(n), b(n); for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { cin >> b[i]; } ll ans = 0; ll max_score = -1; vector ids(n, 0); iota(ids.begin(), ids.end(), 0); do { ll score = 0; for (int ii = 0; ii < n; ++ii) { int i = ids[ii]; score += max(a[i] - b[ii], 0LL); } if (score > max_score) { ans = 1; max_score = score; } else if (score == max_score) ++ans; } while (next_permutation(ids.begin(), ids.end())); cout << ans << newl; return 0; }