#include <cstdio>
#include <cstring>

#define m 1000000
#define mm 1000000
#define ml 6

char is[mm], s[m];
int k, l = 0, p[ml + 1];

int main()
{
  freopen("string.in", "r", stdin);
  freopen("string.out", "w", stdout);
  p[0] = 1;
  for (int i = 0; i < ml; i++)
    p[i + 1] = p[i] * 10;
  memset(is, 0, sizeof(is));
  s[0] = 0;
  scanf("%d", &k);
  for (int i = 1; i <= k; i++)
  {
    if (is[i])
      continue;
    sprintf(s + l, "%d", i);
    while (s[l])
    {
      l++;
      int t = 0;
      for (int j = 0; j < ml && l - 1 - j >= 0; j++)
      {
        t += p[j] * (s[l - 1 - j] - '0');
        if (s[l - 1 - j] != '0')
          is[t] = 1;
      }
    }
  }
  puts(s);
  return 0;
}
