#include
#include
using namespace std;
int main()
{
size_t pos444, pos777;
string str(31, '4');
do
{
pos444 = str.find("444");
if (pos444 != string::npos) str.replace(pos444, 3, "7");
pos777 = str.find("777");
if (pos777 != string::npos) str.replace(pos777, 3, "4");
} while (pos444 != string::npos || pos777 != string::npos);
cout << str;
}
774