#define _USE_MATH_DEFINES #include using namespace std; //template #define rep(i,a,b) for(int i=(a);i<(b);i++) #define rrep(i,a,b) for(int i=(a);i>(b);i--) #define ALL(v) (v).begin(),(v).end() typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x3fffffffffffffff; template inline bool chmax(T& a,T b){ if(a inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; } //template end int dp[3010][3010]; int main(){ int n; scanf("%d",&n); vector a(n+1),b(n+1),d(n); rep(i,0,n+1)scanf("%d",&a[i]); rep(i,0,n+1)scanf("%d",&b[i]); rep(i,0,n)scanf("%d",&d[i]); sort(ALL(d)); dp[0][0]=inf; rep(i,0,n+1)rep(j,0,n+1){ if(i==0&&j==0)continue; int idx=upper_bound(ALL(d),a[i]+b[j])-d.begin()-1,ma=0; if(i)chmax(ma,dp[i-1][j]); if(j)chmax(ma,dp[i][j-1]); dp[i][j]=min(idx,ma-1); } int ans=0; rep(i,0,n+1)rep(j,0,n+1)if(dp[i][j]>=0)chmax(ans,i+j); printf("%d\n",ans); return 0; }