Can any one fix errors(exceptions)......
import java.util.Scanner; class Waste{ public static void main(String args[]){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); char AL,AR,BU,BD; int z=0,y=0; int p=0; int k=sc.nextInt(); char a[]=new char[k]; char b[]=new char[k]; char t; String s=sc.nextLine(); b[0]=a[0]; for(int i=0;i<k;i++) { a[i]=s.charAt(i); if((a[0]=='L')|(a[0]=='R')) if((a[i]!='L')|(a[i]!='R')) { p++; b[p]=a[i]; t=a[0]; a[0]=a[i]; a[i]=t; } if((a[0]=='U')|(a[0]=='D')) if((a[i]!='U')|(a[i]!='D')) { p++; b[p]=a[i]; t=a[0]; a[0]=a[i]; a[i]=t; } } for(int i=0;i<k;i++) { if(b[i]=='\0') break; switch(b[i]) { case 'R': z+=1; break; case 'L': z-=1; break; case 'U': y+=1; break; case 'D': y-=1; break; } } System.out.println("("+z+","+y+")")