well, i started to type this as pseudocode but it turns out it might be valid (GNU) C++ 
main()
{
int s[]={[0 ... 255] = 0}, n, c, m=0, b;
cin>>n;
while(n--)
if ((++s[c=getchar()])>m || (s[c]==m && c<b))
m=s[b=c];
cout<<(char)b;
}
i didnt test it, so it probably wont work, but thats my 60-seconds-worth of answer 
(edit: 62 seconds. i forgot to cast b to char for the cout)