NR%3==1 {split($0,arr,"");for(a in arr){A[arr[a]]=1}} NR%3==2 {split($0,arr,"");for(a in arr){B[arr[a]]=1}} NR%3==0 { split($0,arr,"") for (a in arr) { c = arr[a] if ((c in A)&&(c in B)) {comm = c} } S += index("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", comm) delete A delete B } END {print S}