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

void main() {
    int n, m, k;
    scan(n, m, k);
    auto a = readln.split.to!(long[]);
    auto b = readln.split.to!(long[]);
    auto as = new long[](n + 1);
    auto bs = new long[](m + 1);
    foreach (i; 1 .. n + 1) {
        as[i] = as[i - 1] + a[i - 1];
    }
    foreach (i; 1 .. m + 1) {
        bs[i] = bs[i - 1] + b[i - 1];
    }
    debug {
        writeln(as);
        writeln(bs);
    }
    int ans;
    foreach (i; 0 .. n + 1) {
        auto d = k - as[i];
        if (d < 0)
            break;

        auto j = bs.assumeSorted.lowerBound(d + 1).length.to!int - 1;
        debug {
            writefln("%s, %s, %s", d, i, j);
        }
        chmax(ans, i + j);
    }
    writeln(ans);
}

void scan(T...)(ref T args) {
    auto line = readln.split; // @suppress(dscanner.suspicious.unmodified)
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args)
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args)
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}
