#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
struct data {
    ll weight; int start, last, index;
    data(ll w, int S, int L, int I) {
        weight = w; start = S; last = L; index = I;
    }
    bool operator<(data other) const
    {
        return weight > other.weight;
    }
};
 
 
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
 
    int N, M, K; //cin >> N >> M >> K;
    N = 100;
	M = 4950;
	K = 4852;
    vector<vpl> graph(N);
    /*F0R(i, M) {
        ll A, B, C; cin >> A >> B >> C; A--; B--;
        graph[A].pb(mp(C, B));
        graph[B].pb(mp(C, A));
    }*/
    for(int i=0; i<=N-3; i++) {
        for(int j=i+1; j<=N-2; j++) {
            graph[i].pb(mp(1, j));
            graph[j].pb(mp(1, i));    
        }
    }
    for(int i=0; i<=N-2; i++) {
        graph[i].pb(mp(1000000000, N-1));
        graph[N-1].pb(mp(1000000000, i));
    }
  
    F0R(i, N) {
        sort(all(graph[i]));
    }
 
    priority_queue<data> pq; //-weight, edge index, start, next-to-last.
    K *= 2;
    set<pl> visited;
    F0R(i, N) {
        pq.push(data(graph[i][0].f, i, i, 0));
        visited.insert(mp(i, i));
    }
    int pops_count = 0;
    while (!pq.empty()) {
        data cur = pq.top();
        pq.pop();
        pops_count++;
        int nxt = graph[cur.last][cur.index].s;
        if (!visited.count(mp(cur.start, graph[cur.last][cur.index].s))) {
            visited.insert(mp(cur.start, graph[cur.last][cur.index].s));
            //cout << cur.start << " " << nxt << " " << cur.weight << endl;
            K--;
            if (K == 0) {
                cout << "pops count is " << pops_count << endl;
                cout << cur.weight << endl; return 0;
            }
            pq.push(data(cur.weight + graph[nxt][0].f, cur.start, nxt, 0));
        }
        if (cur.index + 1 < sz(graph[cur.last])) {
            pq.push(data(cur.weight - graph[cur.last][cur.index].f + graph[cur.last][cur.index + 1].f, cur.start, cur.last, cur.index + 1));
        }
 
    }
 
    return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343