import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "next", long, "cost");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);

void main()
{
    long n, m, k;
    scan(n, m, k);
    auto a = aryread();
    auto b = aryread();
    iota(n - 1).each!(x => a[x + 1] += a[x]);
    iota(m - 1).each!(x => b[x + 1] += b[x]);
    a = only(0).array.chain(a).array();
    long bseach(long rest)
    {
        long ok = -1, ng = m;
        while (abs(ok - ng) > 1)
        {
            auto mid = (ok + ng) / 2;
            if (b[mid] <= rest)
                ok = mid;
            else
                ng = mid;
        }
        return ok + 1;
    }

    long num;
    (n + 1).iota.each!(x => num = max(num, (a[x] < k ? x + bseach(k - a[x]) : 0)));
    num.writeln();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}
