#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int solution(string dirs) {
int answer = 0;
int x = 0; //좌우
int y = 0; //상하
int dx = 0; //좌우방향
int dy = 0; //상하방향
int len = dirs.size();
vector<vector<vector<int>>> log;
//이동좌표, 이전좌표 저장
for(int i = 0; i<len; i++){
if(dirs[i] == 'U' && y < 5){
y++;
dy=-1;
}
else if(dirs[i] == 'D' && y > -5){
y--;
dy=1;
}
else if(dirs[i] == 'R' && x < 5){
x++;
dx=-1;
}
else if(dirs[i] == 'L' && x > -5){
x--;
dx=1;
}
if (dx == 0 && dy == 0) {
continue;
}
vector<vector<int>> path = {{x, y}, {x+dx, y+dy}};
sort(path.begin(), path.end());
log.push_back(path);
dx=0;
dy=0;
}
sort(log.begin(), log.end());
log.erase(unique(log.begin(),log.end()), log.end());
answer = log.size();
return answer;
}