#include <stdio.h>

int main() {
    char isbn[14];
    scanf("%s",isbn);
    int chk_num = isbn[12]-'0';
    int acc=0, dmg_weight;
    for(int i=0; i<12; i++) {
        if(isbn[i] != '*') {
            if(i%2==0) acc += isbn[i] - '0';
            else acc += 3*(isbn[i] - '0');
        }
        else {
            if(i%2==0) dmg_weight = 1;
            else dmg_weight = 3;
        }
    }
    int res = 0;
    while(1) {
        if((chk_num + acc + (dmg_weight*res))%10 == 0 ) {
            printf("%d\n",res);
            break;
        }
        res++;
    }

    return 0;
}