It seems like the year of 2013 came only yesterday. Do you know a curious fact? The year of 2013 is the first year after the old 1987 with only distinct digits.

Now you are suggested to solve the following problem: given a year number, find the minimum year number which is strictly larger than the given one and has only distinct digits.
The single line contains integer *y* (1000 ≤ *y* ≤ 9000) — the year number.
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#define     no                         cout << "NO\n"
#define     yes                        cout << "YES\n"
#define     yn                         "YES\n":"NO\n"
#define     ny                         "NO\n":"YES\n"
#define     oyn                        (ok)?"YES\n":"NO\n"
#define     ony                        (ok)?"NO\n":"YES\n"
#define     nl                         printf("\n");
#define     YES                        printf("YES\n")
#define     NO                         printf("NO\n")

#define     btr                        bool ok=true
#define     bfl                        bool ok=false
#define     bo0                        bool ok=0
#define     rt                         return true
#define     rf                         return false

#define     li                         long int
#define     lli                        long long int
#define     ui                         unsigned int
#define     ulli                       unsigned long long int
#define     ll                         long long
#define     ld                         long double
#define     sic                        signed char
#define     uc                         unsigned char
#define     itr                        ::iterator

#define     vi                         vector<int>
#define     vb                         vector<bool>
#define     vs                         vector<string>
#define     vll                        vector<long long>

#define     mpii                        map<int, int>
#define     mpci                        map<char, int>
#define     mpll                        map<ll, ll>
#define     mplli                       map<ll, int>
#define     mplili                      map<ll int, ll int>
#define     mpsi                        map<string, int>
#define     mpis                        map<int, string>
#define     mpipii                      map<pair<int, int>, int>
#define     mpipcc                      map< pair< char, char >, int >

#define     si                         set<int>
#define     sc                         set<char>
#define     sigi                       set<int, greater<int> >
#define     sll                        set<ll>
#define     msi                        multiset<int>
#define     msl                        multiset<ll>

#define     pii                        pair<int,int>
#define     plili                      pair<ll int, ll int>
#define     pll                        pair<ll,ll>
#define     psi                        pair<string,int>
#define     psl                        pair<string,ll>
#define     pci                        pair<char,int>
#define     pcl                        pair<char,ll>

#define     e4                         int main()
#define     ec                         return 0;
#define     ff                         first
#define     ss                         second
#define     sp                         << " "
#define     spa                        << " " <<
#define     pb                         push_back
#define     cn                         continue
#define     br                         break
#define     in                         insert
#define     I                          std::cin>>
#define     O                          std::cout<<
#define     E                          << endl
#define     a0                         int ans=0
#define     lla0                       ll ans=0
#define     xy0(x,y)                   int x=0,y=0
#define     xyz0(x,y,z)                int x=0,y=0,z=0

#define     sz                         size()
#define     bg                         begin()
#define     en                         end()
#define     erase_duplicates(x)        x.erase(unique(all(x)),x.end());
#define     all(x)                     x.begin(),x.end()
#define     all_0(x)                   memset(x,0,sizeof(x))
#define     all_neg(x)                 memset(x,-1,sizeof(x))
#define     all_1(x)                   memset(x,1,sizeof(x))
#define     rrp                        regex_replace
#define     rrm                        regex_match
#define     pb                         push_back
#define     pob                        pop_back
#define     mp                         make_pair

#define     test_case(t)               int t; cin >> t; while(t--)
#define     test_case_strIn            int t; string s; cin>>t; while(t--&&cin>>s)
#define     test_case_intIn            int t,n; cin>>t; while(t--&&cin>>n)
#define     test_case_two              int t,n; cin>>t; while(t-- && cin>>n) while(n--)
#define     test_case_TWOsecondIn      int t,n,x; cin>>t; while(t-- && cin>>n) while(n-- && cin>>x)

#define     test_caseFor               int t; for(cin>>t;t--;)
#define     test_in_For_twoIN(t,a,b)   int t;cin>>t;for(int a,b; t ; --t)

#define     if_ev(n)                   if(n%2==0)
#define     if_od(n)                   if(n%2==1)
#define     if_one(n)                  if(n==1)
#define     if_zero(n)                 if(n==0)

#define     fr(i,n)                    for(int i=0;i<n;i++)
#define     fr1(i,n)                   for(ll i=1;i<=n;i++)

#define     char_in(x)                      char x; cin >> x
#define     char_ins(x)                     scanf(" %c",&x)
#define     char_size(x)                    (x.begin() ,x.end()).size()

#define     str_in(x)                       string x; cin>>x
#define     str_in1(x)                      scanf("%s",&x)
#define     sortA(x)                        sort(x.begin(),x.end())
#define     str_reverse(x)                  reverse(x.begin(),x.end());
#define     str_increaseForLoop(s,o)        string s; cin>>s; for(int i=o; i<s.size(); ++i)

#define     int_in(x)                       int x; cin >> x
#define     int_in2(x,y)                     int x,y; cin >> x >> y
#define     int_in3(x,y,z)                   int x,y,z; cin >> x >> y >> z
#define     int_in4(w,x,y,z)                   int w,x,y,z; cin >> w >> x >> y >> z
#define     int_ins(x)                      int x; scanf("%d",&x)
#define     int_ins2(x,y)                   int x,y; scanf("%d %d",&x,&y)
#define     int_ins3(x,y,z)                 int x,y,z; scanf("%d %d %d",&x,&y,&z)
#define     int_out(x)                      printf("%d",x)

#define     is_in(x,y)                       int x; string y; cin >> x >> y

#define     ll_in(x)                        long long x; scanf("%lld",&x)
#define     ll_in2(x,y)                     long long x,y; scanf("%lld %lld",&x,&y)
#define     ll_in3(x,y,z)                   long long x,y,z; scanf("%lld %lld %lld",&x,&y,&z)
#define     ll_out(x)                       printf("%lld",&x)
#define     ll_out2(x,y)                    printf("%lld %lld",&x ,&y)
#define     ll_out3(x,y,z)                  printf("%lld %lld %lld",&x, &y, &z)

#define     take_the_array_INT(x,o,n)       for(int i=o; i<=n; i++){scanf("%d",&x[i]);}
#define     take_the_array_LL(x,o,n)        for(int i=o; i<=n; i++){scanf("%lld",&x[i]);}
#define     take_the_array_DBL(x,o,n)       for(int i=o; i<=n; i++){scanf("%lf",&x[i]);}
#define     print_the_array_INT(x,o,n)      for(int i=o; i<=n; i++){printf("%d ",x[i]);}printf("\n");
#define     print_the_array_LL(x,o,n)       for(int i=o; i<=n; i++){printf("%lld ",x[i]);}printf("\n");
#define     cin_the_array(x,o,n)            for(int i=o; i<n; i++){cin>>x[i];}
#define     cout_the_array(x,o,n)           for(int i=o; i<n; i++){cout<<x[i]<<" ";}cout<<endl;
#define     cin_the_arrayEQ(x,o,n)          for(int i=o; i<=n; i++){cin>>x[i];}
#define     cout_the_arrayEQ(x,o,n)         for(int i=o; i<=n; i++){cout<<x[i]<<" ";}cout<<endl;

#define     in_range(i,x,y)                 for(int i=x; i<y; i++)
#define     in_range_back(i,y,x)            for(int i=y; i>x; i--)
// #define     in_range_back(i,x,y)            for(int i=y; i>x; i--)

#define     in_rangeEQ(i,x,y)               for(int i=x; i<=y; i++)
#define     in_range_backEQ(i,y,x)          for(int i=y; i>=x; i--)
// #define     in_range_backEQ(i,x,y)          for(int i=y; i>=x; i--)
//in for in range loop md
using namespace std;
e4{
   //ekta sal diya thakbe seta er porer jekono ekta sal output korte hobe jate 4 ta number e vinno hoy like 2015,2016,3012
      int_in(a);
      for(; ;){
         a++;
         int b=a/1000;
         int c=(a/100)%10;
         int d=(a/10)%10;
         int e=(a%10);
         if(a!=b && a!=c && a!=d && b!=c && b!=c && b!=d && c!=d) br;
      }
      O a;
   ec
}