#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int hierarchy(int num);

int main(void) {
    int num, count, i, j, k;
    
    while(scanf("%d", &num) != EOF) {
        int ans = 0;
        switch(hierarchy(num)) {
            case 1:
                j = 6;
                k = 4;
                count = 0;
                for(i = 4; num != count++; ) {
                    ans = i;
                    if(num == count) break;
                    if(count > 1) j += k++;
                    i += j;
                }
                break;
            case 2:
                j = 66;
                k = 1;
                count = 9;
                for(i = 282; num != count++; ) {
                    ans = i;
                    if(num == count) break;
                    if(count > 10) {
                        j += k;
                        k -= 3;
                    }
                    i += j;
                }
                break;
            case 3:
                j = -41;
                k = -11;
                count = 19;
                for(i = 633; num != count++; ) {
                    ans = i;
                    if(num == count) break;
                    if(count > 20) {
                        j += k;
                        k += 3;
                    }
                    i += j;
                }
                break;
            case 4:
                j = -28;
                k = 7;
                count = 29;
                for(i = 84; num != count++; ) {
                    ans = i;
                    if(num == count) break;
                    if(count > 30) j += k--;
                    i += j;
                }
                break;
            default : break;
        }
        cout << ans << endl;
    }
    
    return(0);
}

int hierarchy(int num) {
    if(num >= 0 && num <= 9)
        return(1);
    else if(num >= 10 && num <= 19)
        return(2);
    else if(num >= 20 && num <= 29)
        return(3);
    else if(num >= 30 && num <= 36)
        return(4);
    else
        return(5);
}