#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
void main()
{
  int x,jed,des,sto,hilj;
  scanf("%d",&x);
  if(x<1000 || x>9999)
  {
    printf("-1");
    exit(1);
  }
  jed=x%10;
  hilj=x/1000;
  sto=(x/100)%10;
  des=(x/10)%10;
  if(jed%2!=0)
    jed=jed-1;
  if(des%2!=0)
    des=des-1;
  if(sto%2!=0)
    sto=sto-1;
  if(hilj%2!=0)
    hilj=hilj-1;
  x=(hilj*1000)+(sto*100)+(des*10)+jed;
  
  
  printf("%d",x);

  
}