~cpp
// 10049 - Self-describingSequence
#include <iostream>
using namespace std;
#define MAX 673366
static int table[MAX];
void initTable()
{
int number = 2;
int count = 0;
table[1] = 1;
table[2] = 2;
table[3] = 2;
for (int i = 4; i < MAX; i++)
{
if (count == 0)
{
number++;
count = table[number];
}
count--;
table[i] = number;
}
}
void calcCumulate()
{
for (int i = 1; i < MAX - 1; i++)
table[i + 1] += table[i];
}
void preProcess()
{
initTable();
calcCumulate();
}
void process(int n)
{
int i;
for (i = 1; i < MAX; i++)
if (n < table[i])
break;
if (n == table[i-1])
i--;
cout << i << endl;
}
int main()
{
int n;
preProcess();
while (cin >> n && n != 0)
process(n);
return 0;
}