#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;
set<int> g[300000];
vi h;
int p[300000], q[300000];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n = 300000;
int m = n/2;
for (int i = 0; i < n; ++i)
{
p[i] = (i+1);
p[i]--;
q[p[i]] = i;
}
for (int i = 0; i < m; ++i)
{
int u, v;
u = (i+1);
v = n;
g[v - 1].insert(u - 1);
if (v - 1 == p[n - 1])
h.push_back(u - 1);
}
sort(all(h), [](int a, int b) { return q[a] > q[b]; });
int pos = n - 1, sol = 0;
vi bad;
for (int x : h)
{
for (int i = q[x] + 1; i < pos; ++i)
bad.push_back(p[i]);
bool good = true;
for (int y : bad)
if (g[y].find(x) == g[y].end())
good = false;
if (!good)
break;
sol++;
pos = q[x];
}
cout << sol;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgYWxsKHgpIHguYmVnaW4oKSwgeC5lbmQoKQojZGVmaW5lIGRiZyh4KSBjZXJyIDw8ICN4IDw8ICIgPSAiIDw8IHggPDwgZW5kbAojZGVmaW5lIF8gPDwgJyAnIDw8CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CnVzaW5nIGxsID0gbG9uZyBsb25nOwp1c2luZyB2aSA9IHZlY3RvcjxpbnQ+Owp1c2luZyBpaSA9IHBhaXI8aW50LCBpbnQ+Owp1c2luZyB2aWkgPSB2ZWN0b3I8aWk+OwoKc2V0PGludD4gZ1szMDAwMDBdOwp2aSBoOwppbnQgcFszMDAwMDBdLCBxWzMwMDAwMF07CgppbnQgbWFpbigpCnsKICAgIGlvczo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTsKICAgIGNpbi50aWUoMCk7CiAgICBpbnQgbiA9IDMwMDAwMDsKICAgIGludCBtID0gbi8yOwogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyArK2kpCiAgICB7CiAgICAgICAgcFtpXSA9IChpKzEpOwogICAgICAgIHBbaV0tLTsKICAgICAgICBxW3BbaV1dID0gaTsKICAgIH0KCiAgICBmb3IgKGludCBpID0gMDsgaSA8IG07ICsraSkKICAgIHsKICAgICAgICBpbnQgdSwgdjsKICAgICAgICB1ID0gKGkrMSk7CiAgICAgICAgdiA9IG47CiAgICAgICAgZ1t2IC0gMV0uaW5zZXJ0KHUgLSAxKTsKICAgICAgICBpZiAodiAtIDEgPT0gcFtuIC0gMV0pCiAgICAgICAgICAgIGgucHVzaF9iYWNrKHUgLSAxKTsKICAgIH0KCiAgICBzb3J0KGFsbChoKSwgW10oaW50IGEsIGludCBiKSB7IHJldHVybiBxW2FdID4gcVtiXTsgfSk7CiAgICBpbnQgcG9zID0gbiAtIDEsIHNvbCA9IDA7CiAgICB2aSBiYWQ7CiAgICBmb3IgKGludCB4IDogaCkKICAgIHsKICAgICAgICBmb3IgKGludCBpID0gcVt4XSArIDE7IGkgPCBwb3M7ICsraSkKICAgICAgICAgICAgYmFkLnB1c2hfYmFjayhwW2ldKTsKCiAgICAgICAgYm9vbCBnb29kID0gdHJ1ZTsKICAgICAgICBmb3IgKGludCB5IDogYmFkKQogICAgICAgICAgICBpZiAoZ1t5XS5maW5kKHgpID09IGdbeV0uZW5kKCkpCiAgICAgICAgICAgICAgICBnb29kID0gZmFsc2U7CgogICAgICAgIGlmICghZ29vZCkKICAgICAgICAgICAgYnJlYWs7CgogICAgICAgIHNvbCsrOwogICAgICAgIHBvcyA9IHFbeF07CiAgICB9CiAgICBjb3V0IDw8IHNvbDsKfQ==