public static String compact(String str) {
	 char[] array=str.toCharArray();
	 char lastChar='a';
	 String carrRtn="\\n";
	 String tabRtn="\\t";
	 int counter=0;
	 StringBuffer sb=new StringBuffer();
	 for (int i=0;i<array.length;i++) {
	   if (i==0 || array[i]!=lastChar) {
		 if (counter>1) {
		   sb.append(counter);
		 }
		 lastChar=array[i];
		 counter=1;
		 if (lastChar=='\n') {
		   sb.append(carrRtn);
		 }
		 else if (lastChar=='\t') {
		   sb.append(tabRtn);
		 }
		 else {
		   sb.append(lastChar);
		 }
	   }
	   else {
		 counter++;
	   }
	 }
	 if (counter==2) {
	   sb.append(counter);  
	 }
	 else if (counter>2) {
	   sb.append("3+");
	 }
	 return(sb.toString());
   }