#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
int memo[500][500];
bool sht[500][500];
int rec(int L, int R, vector<int> &arr) {
  if (sht[L][R]) return memo[L][R];
  sht[L][R] = 1;
  if (L == R) return memo[L][R] = 1;
  int mi = 500;
  int idx;
  for (int i = L; i <= R; ++i) {
    if (arr[i] < mi) {
      mi = arr[i];
      idx = i;
    }
  }
  int rig = (idx == R) ? 1 : rec(idx + 1, R, arr);
  for (int i = idx + 1; i <= R; i++)
    rig =
        (rig + 1LL * rec(idx + 1, i, arr) * (i == R ? 1 : rec(i + 1, R, arr))) %
        MOD;
  int lef = (idx == L) ? 1 : rec(L, idx - 1, arr);
  for (int i = idx - 1; i >= L; i--)
    lef =
        (lef + 1LL * rec(i, idx - 1, arr) * (i == L ? 1 : rec(L, i - 1, arr))) %
        MOD;
  return memo[L][R] = 1LL * rig * lef % MOD;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> arr(n);
  for (int i = 0; i != n; ++i) {
    cin >> arr[i];
    arr[i]--;
  }
  cout << rec(0, n - 1, arr) << '\n';
  return 0;
}
