#include <bits/stdc++.h>

#include <algorithm>
#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// mt19937 rng(100);
VI answer;

template <typename T>
struct Node {
    T val, count;
    T lazycount, lazysub;

    int pos;
    int prior;
    Node *l, *r;

    inline void set(T _val, int idx) {
        pos = idx;
        val = _val;
    }
    Node()
        : count(0),
          lazycount(0),
          lazysub(0),
          l(nullptr),
          r(nullptr),
          prior(rng()) {
    }
};
Node<int> nodes[200000 + 1];
int nodecount = 0;
using pnode = Node<int> *;

// tick
inline void pushlazy(pnode t) {
    if (not t)
        return;
    if (t->lazycount) {
        t->count += t->lazycount;
        t->val += t->lazysub;

        if (t->l)
            t->l->lazycount += t->lazycount, t->l->lazysub += t->lazysub;
        if (t->r)
            t->r->lazycount += t->lazycount, t->r->lazysub += t->lazysub;

        t->lazycount = 0;
        t->lazysub = 0;
    }
}

// tick
void split_by_val(pnode t, pnode &l, pnode &r, int val) {
    if (not t) {
        l = r = nullptr;
        return;
    }

    pushlazy(t);

    if (t->val <= val) {
        split_by_val(t->r, t->r, r, val);
        l = t;
    } else {
        split_by_val(t->l, l, t->l, val);
        r = t;
    }
}

// tick
void merge(pnode &t, pnode l, pnode r) {
    pushlazy(l);
    pushlazy(r);
    if (not l or not r)
        t = l ? l : r;
    else if (l->prior > r->prior) {
        merge(l->r, l->r, r);
        t = l;
    } else {
        merge(r->l, l, r->l);
        t = r;
    }
}

void decrement(pnode t, int val) {
    if (t) {
        t->lazysub -= val;
        t->lazycount += 1;
    }
}

// tick
void gen_answer(pnode t) {
    if (not t)
        return;
    pushlazy(t);
    gen_answer(t->l);
    assert(answer[t->pos] == -1);
    answer[t->pos] = t->count;
    gen_answer(t->r);
}

// tick
void insert_by_val(pnode &t, pnode it) {
    if (not t) {
        t = it;
        return;
    }
    if (not it)
        return;
    pushlazy(t);
    if (it->prior > t->prior) {
        split_by_val(t, it->l, it->r, it->val);
        t = it;
    } else if (t->val <= it->val)
        insert_by_val(t->r, it);
    else
        insert_by_val(t->l, it);
}

void insert_all(pnode &target, pnode source) {
    if (not source)
        return;
    pushlazy(source);
    insert_all(target, source->l);
    insert_all(target, source->r);
    source->l = source->r = nullptr;
    insert_by_val(target, source);
}

int maxdepth = 0;
void preorder(pnode treap, int depth = 0) {
    if (treap) {
        maxdepth = max(maxdepth, depth);
        // cout << treap->pos << ": ";
        // cout << (treap->l ? treap->l->pos : -1) << " ";
        // cout << (treap->r ? treap->r->pos : -1) << endl;

        preorder(treap->l, depth + 1);
        preorder(treap->r, depth + 1);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    Node<int> *treap = nullptr;
    int n = 1000;
    for (int i = 0; i < n; i++) {
        auto nd = new Node<int>();
        nd->set(0, i);
        insert_by_val(treap, nd);
    }

    preorder(treap);
    cout << maxdepth << endl;

    return 0;
}
