import java.util.*;

class Solution {
    public String solution(String new_id) {
        Stack<String> stack = new Stack<>();
        
        //1
        String temp1 = new_id.toLowerCase();
        
        //2
        String temp2 = "";
        for(int i=0; i<temp1.length(); i++) {
            char c = temp1.charAt(i);
            if((c>='a' && c<='z') || (c>='0' && c<='9') || c=='-' || c=='_' || c=='.') {
                temp2 += String.valueOf(c);
            }
        }
        
        //3
        String temp3 = "";
        for(int i=0; i<temp2.length(); i++) {
            String s = String.valueOf(temp2.charAt(i));
            
            if(!stack.isEmpty() && stack.peek().equals(".") && s.equals(".")) { continue; }
            
            stack.push(s);
        }
        
        while(!stack.isEmpty()) { temp3 = stack.pop()+temp3; }
        
        //4
        String temp4 = temp3;
        if(temp4.length()>1) {
            if(temp4.charAt(0)=='.') { temp4 = temp4.substring(1,temp4.length()); }
            if(temp4.charAt(temp4.length()-1)=='.') { temp4 = temp4.substring(0,temp4.length()-1); }
        } else if(temp4.equals(".")) { temp4 = ""; }
        
        //5
        String temp5 = temp4.equals("") ? "a" : temp4;
        
        //6
        String temp6 = temp5.length()>=16 ? temp5.substring(0, 15) : temp5;
        while(temp6.charAt(temp6.length()-1)=='.') {
            temp6 = temp6.substring(0, temp6.length()-1);
        }
        
        //7
        String temp7 = temp6;
        while(temp7.length()<=2) {
            temp7 += String.valueOf(temp7.charAt(temp7.length()-1));
        }
        
        return temp7;
    }
}