#include #include using namespace std; int main() { int x, a; char buf[7]; while (~scanf("%d", &x)) { for (a = x + 1;; a++) { sprintf(buf, "%d", a); sort(buf, buf + 4); if (unique(buf, buf + 4) == buf + 4) break; } printf("%d\n", a); } return 0; }