import 'dart:io';

void main(List<String> arguments) {
  final nmk = stdin.readLineSync().split(' ').map((e) => int.parse(e)).toList();
  final n = nmk[0];
  final m = nmk[1];
  final k = nmk[2];
  final a = stdin.readLineSync().split(' ').map((e) => int.parse(e)).toList();
  final b = stdin.readLineSync().split(' ').map((e) => int.parse(e)).toList();
  final result = _c(n, m, k, a, b);
  print(result);
}

int _c(int n, int m, int k, List<int> a, List<int> b) {
  int counter = 0;
  int nextIndexA = 0;
  int nextIndexB = 0;
  int sum = 0;

  bool flag = true;
  while (flag) {
    final nextA = nextIndexA < a.length ? a[nextIndexA] : 0;
    final nextB = nextIndexB < b.length ? b[nextIndexB] : 0;

    if (nextA < nextB) {
      if (sum + nextA < k) {
        sum += nextA;
        counter++;
        nextIndexA++;
      } else {
        flag = false;
      }
    } else {
      if (sum + nextB < k) {
        sum += nextB;
        counter++;
        nextIndexB++;
      } else {
        flag = false;
      }
    }
  }

  return counter;
}
