#include <bits/stdc++.h>
using namespace std;
long long dp[505][505] = {0};
int qwq[505];
int n, m;
long long dfs(int left, int right) {
  if (dp[left][right]) return dp[left][right];
  if (left >= right) return 1;
  int p = left;
  for (int i = left; i <= right; i++)
    if (qwq[i] < qwq[p]) p = i;
  long long ans1 = 0, ans2 = 0;
  for (int i = left; i <= p; i++) {
    ans1 = (ans1 + dfs(left, i - 1) * dfs(i, p - 1) % 998244353) % 998244353;
  }
  for (int i = p; i <= right; i++) {
    ans2 = (ans2 + dfs(p + 1, i) * dfs(i + 1, right) % 998244353) % 998244353;
  }
  long long ans = ans1 * ans2 % 998244353;
  dp[left][right] = ans;
  return ans;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &qwq[i]);
  cout << dfs(1, n) << endl;
  return 0;
}
