#include <stdio.h>
#include "math.h"
int main() {
int n;
int x[100];
int k;
scanf("%d", &n);
int num = 0;
while (n != 0) {
k = n % 10;
x[num] = k;
n = (n - k) / 10;
num ++;
}
for (int i = 0; i < num - 1; ++i) {
int min = i;
for (int j = i + 1; j < num; ++j) {
if (x[min] > x[j]) {
min = j;
}
}
if (min != i) {
int t = x[i];
x[i] = x[min];
x[min] = t;
}
}
int sum1 = 1;
int minnum = 0;
int maxnum = 0;
for (int i = 0; i < num; i++) {
if (x[i] % 2 == 0 || x[i] == 0) {
maxnum += x[i] * sum1;
sum1 *= 10;
}
}
//判断奇数
int sum2 = 1;
for (int i = num - 1; i >= 0; i--) {
if (x[i] % 2 != 0) {
minnum += x[i] * sum2;
sum2 *= 10;
}
}
printf("%d", maxnum - minnum);
return 0;
}