using System;
using System.Linq;
using System.ComponentModel;
using System.Collections.Generic;

namespace ConsoleApp1 {
    public class Class {
        static void Main(string[] args) {
            var (N, M, K) = ReadValue<long, long, long>();
            var A = longRL;
            var B = longRL;
            long ans = 0;
            var C = new long[M + 1];
            for(var i = 0; i < M; i++) {
                C[i + 1] = C[i] + B[i];
            }
            long T = 0;
            for(var i = 0; i <= N; i++) {
                if(i != 0) {
                    T += A[i - 1];
                }
                if (T > K) break;
                long l = -1;
                var r = M + 1;
                while (r - l > 1) {
                    var m = (l + r) / 2;
                    if(T + C[m] <= K) {
                        l = m;
                    } else {
                        r = m;
                    }
                }
                ans = Math.Max(ans, i + l);
            }
            Console.Write(ans);
        }

        static int BinarySearch<T>(T[] arr,Func<T,bool> predicate) {
            int min = 0;
            int max = arr.Length - 1;
            long call = 0;
            while (true) {
                call++;
                var mid = (min + max) / 2;
                if (min == max) {
                    return max;
                }
                if (predicate(arr[mid]) && !predicate(arr[mid + 1])) { 
                    return mid;
                }
                if (predicate(arr[mid])) {
                    min = mid + 1;
                } else {
                    max = mid - 1;
                }
            }
        }

        static (T1, T2) ReadValue<T1, T2>() {
            var rl = Console.ReadLine().Trim().Split().ToArray();
            var t1 = TypeDescriptor.GetConverter(typeof(T1));
            var t2 = TypeDescriptor.GetConverter(typeof(T2));
            return ((T1)t1.ConvertFromString(rl[0]),
                    (T2)t2.ConvertFromString(rl[1]));
        }

        static (T1, T2, T3) ReadValue<T1, T2, T3>() {
            var rl = Console.ReadLine().Trim().Split().ToArray();
            var t1 = TypeDescriptor.GetConverter(typeof(T1));
            var t2 = TypeDescriptor.GetConverter(typeof(T2));
            var t3 = TypeDescriptor.GetConverter(typeof(T3));
            return ((T1)t1.ConvertFromString(rl[0]),
                    (T2)t2.ConvertFromString(rl[1]),
                    (T3)t3.ConvertFromString(rl[2]));
        }

        static (T1, T2, T3, T4) ReadValue<T1, T2, T3, T4>() {
            var rl = Console.ReadLine().Trim().Split().ToArray();
            var t1 = TypeDescriptor.GetConverter(typeof(T1));
            var t2 = TypeDescriptor.GetConverter(typeof(T2));
            var t3 = TypeDescriptor.GetConverter(typeof(T3));
            var t4 = TypeDescriptor.GetConverter(typeof(T4));
            return ((T1)t1.ConvertFromString(rl[0]),
                    (T2)t2.ConvertFromString(rl[1]),
                    (T3)t3.ConvertFromString(rl[2]),
                    (T4)t4.ConvertFromString(rl[3]));
        }

        static (T1, T2, T3, T4,T5) ReadValue<T1, T2, T3, T4,T5>() {
            var rl = Console.ReadLine().Trim().Split().ToArray();
            var t1 = TypeDescriptor.GetConverter(typeof(T1));
            var t2 = TypeDescriptor.GetConverter(typeof(T2));
            var t3 = TypeDescriptor.GetConverter(typeof(T3));
            var t4 = TypeDescriptor.GetConverter(typeof(T4));
            var t5 = TypeDescriptor.GetConverter(typeof(T5));
            return ((T1)t1.ConvertFromString(rl[0]),
                    (T2)t2.ConvertFromString(rl[1]),
                    (T3)t3.ConvertFromString(rl[2]),
                    (T4)t4.ConvertFromString(rl[3]),
                    (T5)t5.ConvertFromString(rl[4]));
        }

        static string[] stringRL => Console.ReadLine().Split().ToArray();
        static int[] intRL => Console.ReadLine().Trim().Split().Select(int.Parse).ToArray();
        static long[] longRL => Console.ReadLine().Trim().Split().Select(long.Parse).ToArray();
        static double[] doubleRL => Console.ReadLine().Trim().Split().Select(double.Parse).ToArray();
        static decimal[] decimalRL => Console.ReadLine().Trim().Split().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 73128