#include <stdio.h>

unsigned char hex2bin(unsigned char c)
{
  if (c >= '0' && c <= '9') return(c - '0');
  else if (c >= 'A' && c <= 'F') return(c + 10 - 'A');
  else if (c >= 'a' && c <= 'f') return(c + 10 - 'a');
  else return(0);
}

main()
{
  char buf[1024];
  unsigned int s, s0;
  int i, l;
  char fin;
  unsigned char d;
  s = 0;
  fin = 0;
  while(fgets(buf, 1023, stdin) != NULL && fin == 0){
    if (buf[1] == '0' && buf[2] == '2') fin = 1;
    else{
      if (strlen(buf) > 9){
	s0 = 0;
	for (i = 1; i < 9; i+=2){
	  s0 += hex2bin(buf[i]) << 4 | hex2bin(buf[i+1]);
	}
	for (i = 9; i < strlen(buf)-4; i+=2){
	  d = hex2bin(buf[i]) << 4 | hex2bin(buf[i+1]);
	  s0 += d;
	  s += d;
	}
	printf("%c%c%c%c Checksum= %X\n", buf[3], buf[4], buf[5], buf[6], (~s0+1) & 0xff);
      }
    }
  }
  printf("Total Checksum= %X", s & 0xffff);
}
