/*
TASK:money
LANG:C++
String Search
Rumen Hristov Hristov
*/
#include <stdio.h>
#include <string>
#include <algorithm>
using namespace std;

int sum(string str)
{
	int s=0;
	int k=str.size();
	for (int i=0;i<k;i++)
		s+=str[i]-'0';
	return s;
}

string big(string a,string b)
{
	int sz1=a.size();
	int sz2=b.size();
	if (sz1>sz2) return a;
	if (sz2>sz1) return b;
	for (int i=0;i<sz1;i++)
		if (a[i]>b[i]) return a;
		else return b;
	return a;
}

int isdigit(char ch)
{
	if (ch>='0'&&ch<='9') return 1;
	return 0;
}

int main()
{
	char ch;
	string s;
	string res;
	int br;

	while((ch=getchar())!='#')
	{
		if (isdigit(ch))
			s+=ch;
		else 
		{
			if (s!="") 
			{
				br=sum(s);
				if (br%3==0) res=big(s,res);
			}
			s="";
		}
	}
	if (s!="")
	{
	br=sum(s);
	if (br%3==0) res=big(s,res);
	}

	if (res=="") res="No";
	
	printf("%s",res.c_str());

	return 0;
}
