import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		String regex = "(?:(START)(?=.*END)|\\G(?!^))((?:(?!START|END)(?>\\\\+\\\"|[^\\r\\n\\\"]))*)\\\"";
        String string = "This \" is START an \" example input END string \"\"\n"
	 + "START This is a \"\" second example END\n"
	 + "This\" is \"a START third example END \" \"\n\n"
	 + "START This is a \"\"\\\"\"\\\\\\\\\\\"\"\" test \"\" test\\\" second example END \" and more \"\"\"\" END \"";
        String subst = "$1$2\\\\\"";
        
        Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
        Matcher matcher = pattern.matcher(string);
        
        String result = matcher.replaceAll(subst);
        
        System.out.println(result);
	}
}