const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;

void async function () {
    // Write your code here
    const token = await readline();
    let ans = 0;
    let left = 0;
    for(let i = 0;i < token.length;i++) {
        if(token[i] == '[') {
            left++
        } else if(token[i] == ']') {
            left--
        }
        ans = Math.max(ans,left);
    }
    console.log(ans)
}()

和牛客题解的思路一样