unittest
{
	assert( [ "3 4 240", "60 90 120", "80 150 80 150" ].solve == 3 );
	assert( [ "3 4 730", "60 90 120", "80 150 80 150" ].solve == 7 );
	assert( [ "5 4 1", "1000000000 1000000000 1000000000 1000000000 1000000000", "1000000000 1000000000 1000000000 1000000000" ].solve == 0 );
}



import std.algorithm;
import std.conv;
import std.format;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = 0L;
	auto m = 0L;
	auto k = 0L;
	input.front.formattedRead!"%s %s %s"( n, m, k );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	input.popFront;
	auto bs = input.front.split.to!( long[] );
	
	auto ans = 0L;
	auto t = 0L;
	auto bc = 0L;
	auto ac = 0L;
	while( ac < as.length && t + as[ ac ] <= k )
	{
		t += as[ ac ];
		ac++;
	}
	while( true )
	{
		while( bc < bs.length && t + bs[ bc ] <= k )
		{
			t += bs[ bc ];
			bc++;
		}
		ans = max( ans, ac + bc );
		if( ac <= 0 ) break;
		ac--;
		t -= as[ ac ];
	}
	return ans;
}
