int (@NotNull String str) { int len = str.length(); int depth = 1; for (int i = 0; i < len; ++i) { char c = str.charAt(i); switch (c) { case '(' -> depth++; case ')' -> depth--; } if (depth == 0) { return i + 1; } } LOG.info("Unexpected output during parse copied files in log command " + str); return -1; }