#include <algorithm>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include <cstring>

using namespace std;

using int64 = long long;

namespace FastIO {
class Scanner {
  static constexpr int buf_size = (1 << 18);
  static constexpr int integer_size = 20;
  char buf[buf_size] = {};
  char *cur = buf, *ed = buf;

 public:
  Scanner() {}

  template <class T>
  inline Scanner& operator>>(T& val) {
    read(val);
    return *this;
  }

 private:
  inline void flush() {
    size_t len = ed - cur;
    memmove(buf, cur, len);
    char* tmp = buf + len;
    ed = tmp + fread(tmp, 1, buf_size - len, stdin);
    *ed = 0;
    cur = buf;
  }

  inline void skip_space() {
    while (true) {
      if (cur == ed) flush();
      while (*cur == ' ' || *cur == '\n') ++cur;
      if (__builtin_expect(cur != ed, 1)) return;
    }
  }

  template <class T, std::enable_if_t<std::is_same<T, int>::value, int> = 0>
  inline void read(T& num) {
    skip_space();
    if (cur + integer_size >= ed) flush();
    //bool neg = false;
    num = 0;
    //while (!std::isdigit(*cur) && *cur != '-') ++cur;
    while (!('0' <= *cur && *cur <= '9')) ++cur;
    //if (*cur == '-') neg = true, ++cur;
    while ('0' <= *cur && *cur <= '9') num = num * 10 + (*cur - '0'), ++cur;
    //if (neg) num = -num;
  }

  template <class T, std::enable_if_t<std::is_same<T, int64>::value, int> = 0>
  inline void read(T& num) {
    skip_space();
    if (cur + integer_size >= ed) flush();
    //bool neg = false;
    num = 0;
    //while (!std::isdigit(*cur) && *cur != '-') ++cur;
    while (!('0' <= *cur && *cur <= '9')) ++cur;
    //if (*cur == '-') neg = true, ++cur;
    while ('0' <= *cur && *cur <= '9') num = num * 10 + (*cur - '0'), ++cur;
    //if (neg) num = -num;
  }

  template <class T,
            std::enable_if_t<std::is_same<T, std::string>::value, int> = 0>
  inline void read(T& str) {
    skip_space();
    if (cur + str.size() >= ed) flush();
    auto it = cur;
    while (!std::isspace(*cur)) ++cur;
    str = std::string(it, cur);
  }

  template <class T, std::enable_if_t<std::is_same<T, char>::value, int> = 0>
  inline void read(T& c) {
    skip_space();
    if (cur + 1 >= ed) flush();
    c = *cur, ++cur;
  }

  template <class T, std::enable_if_t<std::is_same<T, double>::value, int> = 0>
  inline void read(T& num) {
    skip_space();
    if (cur + integer_size >= ed) flush();
    bool neg = false;
    num = 0;
    if (*cur == '-') neg = true, ++cur;
    while (std::isdigit(*cur)) num = num * 10 + (*cur - '0'), ++cur;
    if (*cur != '.') return;
    ++cur;
    T base = 0.1;
    while (std::isdigit(*cur)) {
      num += base * (*cur - '0');
      ++cur;
      base *= 0.1;
    }
    if (neg) num = -num;
  }

  template <class T,
            std::enable_if_t<std::is_same<T, long double>::value, int> = 0>
  inline void read(T& num) {
    skip_space();
    if (cur + integer_size >= ed) flush();
    bool neg = false;
    num = 0;
    if (*cur == '-') neg = true, ++cur;
    while (std::isdigit(*cur)) num = num * 10 + (*cur - '0'), ++cur;
    if (*cur != '.') return;
    ++cur;
    T base = 0.1;
    while (std::isdigit(*cur)) {
      num += base * (*cur - '0');
      ++cur;
      base *= 0.1;
    }
    if (neg) num = -num;
  }

  template <class T>
  inline void read(std::vector<T>& vec) {
    for (T& e : vec) read(e);
  }

  template <class T, class U>
  inline void read(std::pair<T, U>& p) {
    read(p.first, p.second);
  }

  template <class Tuple, std::size_t... Is>
  inline void tuple_scan(Tuple& tp, std::index_sequence<Is...>) {
    (read(std::get<Is>(tp)), ...);
  }

  template <class... Args>
  inline void read(std::tuple<Args...>& tp) {
    tuple_scan(tp, std::index_sequence_for<Args...>{});
  }

  inline void read() {}

  template <class Head, class... Tail>
  inline void read(Head&& head, Tail&&... tail) {
    read(head);
    read(std::forward<Tail>(tail)...);
  }
};

class Printer {
  static constexpr int buf_size = (1 << 18);
  static constexpr int integer_size = 20;
  static constexpr int margin = 1;
  char buf[buf_size + margin] = {};
  char integer[integer_size + margin] = {};
  char* cur = buf;

 public:
  Printer() {}

  ~Printer() { flush(); }

  template <class T>
  inline Printer& operator<<(T val) {
    write(val);
    return *this;
  }

 private:
  inline void flush() {
    fwrite(buf, 1, cur - buf, stdout);
    cur = buf;
  }

  template <class T, std::enable_if_t<std::is_same<T, char>::value, int> = 0>
  inline void write(T c) {
    if (__builtin_expect(cur + 1 >= buf + buf_size, 0)) flush();
    *cur = c;
    ++cur;
  }

  template <class T,
            std::enable_if_t<std::is_same<T, std::string>::value, int> = 0>
  inline void write(T str) {
    if (__builtin_expect(cur + str.size() >= buf + buf_size, 0)) flush();
    for (char c : str) write(c);
  }

  template <class T, std::enable_if_t<std::is_same<T, int>::value, int> = 0>
  inline void write(T num) {
    if (__builtin_expect(cur + integer_size >= buf + buf_size, 0)) flush();
    if (num == 0) {
      write('0');
      return;
    }
    if (num < 0) {
      write('-');
      num = -num;
    }
    char* tmp = integer + sizeof(integer);
    T y = num;
    size_t len = 0;
    while (y > 0) {
      *--tmp = y % 10 + '0';
      y /= 10;
      ++len;
    }
    memcpy(cur, tmp, len);
    cur += len;
  }

  template <class T, std::enable_if_t<std::is_same<T, int64>::value, int> = 0>
  inline void write(T num) {
    if (__builtin_expect(cur + integer_size >= buf + buf_size, 0)) flush();
    if (num == 0) {
      write('0');
      return;
    }
    if (num < 0) {
      write('-');
      num = -num;
    }
    char* tmp = integer + sizeof(integer);
    T y = num;
    size_t len = 0;
    while (y > 0) {
      *--tmp = y % 10 + '0';
      y /= 10;
      ++len;
    }
    memcpy(cur, tmp, len);
    cur += len;
  }
};
}  // namespace FastIO

FastIO::Scanner sc;
FastIO::Printer pr;


template <class _Tp>
class CumulativeSum {
 public:
  CumulativeSum(const std::vector<_Tp>& vec) : vec_(vec) { build(); }

  // return sum of [l, r]
  _Tp get(int l, int r) { return sum_[r + 1] - sum_[l]; }

  // return the first k where sum of [0, k] >= value
  // use only when all element in vec >= 0
  int lower_bound(_Tp value) {
    return std::distance(sum_.begin() + 1,
                         std::lower_bound(sum_.begin() + 1, sum_.end(), value));
  }

  // return the first k where sum of [0, k] > value
  // use only when all element in vec >= 0
  int upper_bound(_Tp value) {
    return std::distance(sum_.begin() + 1,
                         std::upper_bound(sum_.begin() + 1, sum_.end(), value));
  }

 private:
  std::vector<_Tp> vec_;
  std::vector<_Tp> sum_;

  void build() {
    sum_.assign(vec_.size() + 1, static_cast<_Tp>(0));
    for (size_t i = 0; i < vec_.size(); ++i) {
      sum_[i + 1] = sum_[i] + vec_[i];
    }
  }
};


int main() {
  int n, m, k; sc >> n >> m >> k;
  vector<int64> a(n), b(m); sc >> a >> b;
  CumulativeSum<int64> csa(a);
  CumulativeSum<int64> csb(b);
  
  int high = n + m + 1, low = 0;

  while (high - low > 1) {
    int mid = (high + low) >> 1;
    int64 need = 1e18;
    int can = 0;

    if (n >= mid) need = min(need, csa.get(0, mid - 1));
    if (m >= mid) need = min(need, csb.get(0, mid - 1));

    for (int i = 0; i < n; ++i) {
      if (mid - i - 2 < 0 || mid - i - 2 >= m) continue;
      need = min(need, csa.get(0, i) + csb.get(0, mid - i - 2));
    }

    if (need > k) {
      high = mid;
    } else {
      low = mid;
    }
  }

  pr << low << '\n';

  return 0;
}


Measured memory_bytes: 13240