#include <bits/stdc++.h>
namespace patch {
template <typename T>
std::string to_string(const T& n) {
  std::ostringstream stm;
  stm << n;
  return stm.str();
}
}  // namespace patch
using namespace std;
bool chk(long long int H, long long int M) {
  string X;
  if (H < 10) {
    X += "0";
  }
  X += patch::to_string(H);
  X += ":";
  if (M < 10) {
    X += "0";
  }
  X += patch::to_string(M);
  for (int i = 0; i < X.size() / 2; i++) {
    if (X[i] != X[X.size() - i - 1]) {
      return false;
    }
  }
  return true;
}
int main() {
  long long int H, M, cn = 0;
  char x;
  cin >> H >> x >> M;
  while (1) {
    if (chk(H, M)) {
      cout << cn;
      break;
    }
    cn++;
    M++;
    if (M == 60) {
      M = 0;
      H++;
    }
    if (H == 24) {
      H = 0;
    }
  }
  return 0;
}
